@DELETE @Path("servers/{id}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response deleteServerTemplate( @Context HttpHeaders headers, @PathParam("id") String serverTemplateId) { try { super.deleteServerTemplate(serverTemplateId); // return null to produce 204 return null; } catch (KieServerControllerNotFoundException e) { return createCorrectVariant(e.getMessage(), headers, Response.Status.NOT_FOUND); } catch (KieServerControllerException e) { return createCorrectVariant( "Request failed to be processed due to" + e.getMessage(), headers, Response.Status.BAD_REQUEST); } catch (Exception e) { logger.error( "Remove server template with id {} failed due to {}", serverTemplateId, e.getMessage(), e); return createCorrectVariant( "Unknown error " + e.getMessage(), headers, Response.Status.INTERNAL_SERVER_ERROR); } }
public Object engineRead() throws StreamParsingException { try { if (sData != null) { if (sDataObjectCount != sData.size()) { return getCertificate(); } else { sData = null; sDataObjectCount = 0; return null; } } currentStream.mark(10); int tag = currentStream.read(); if (tag == -1) { return null; } if (tag != 0x30) // assume ascii PEM encoded. { currentStream.reset(); return readPEMCertificate(currentStream); } else { currentStream.reset(); return readDERCertificate(currentStream); } } catch (Exception e) { throw new StreamParsingException(e.toString(), e); } }
@Override public void setSymbols(List<List<String>> symbols) { log.info("set symbols called"); clearTickSymbols(); final List<TickParms> tp = new ArrayList<TickParms>(); try { TickParms p; for (List<String> m : symbols) { p = new TickParms(); p.setSymbol(m.get(0)); p.setMinvol(Integer.parseInt(m.get(1))); p.setMaxvol(Integer.parseInt(m.get(2))); p.setPriceBasis(Double.parseDouble(m.get(3))); tp.add(p); } } catch (Exception e) { log.severe("caught exception parsing parms: " + e.getMessage()); } log.info(String.format("calling setSymbols with %d symbols\n", tp.size())); try { ctx.getBean(TickGenerator.class).setSymbols(tp.toArray(new TickParms[] {})); } catch (Exception e) { log.severe("caught exception setting parms: " + e.getMessage()); } }
@GET @Path("servers/{id}/containers") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response listContainerSpec( @Context HttpHeaders headers, @PathParam("id") String serverTemplateId) { String contentType = getContentType(headers); try { logger.debug("Received get containers for server template with id {}", serverTemplateId); Collection<ContainerSpec> containerSpecs = super.listContainerSpec(serverTemplateId); String response = marshal(contentType, new ContainerSpecList(containerSpecs)); logger.debug( "Returning response for get containers for server templates with id {}: {}", serverTemplateId, response); return createCorrectVariant(response, headers, Response.Status.OK); } catch (KieServerControllerNotFoundException e) { return createCorrectVariant(e.getMessage(), headers, Response.Status.NOT_FOUND); } catch (KieServerControllerException e) { return createCorrectVariant( "Request failed to be processed due to" + e.getMessage(), headers, Response.Status.BAD_REQUEST); } catch (Exception e) { logger.error("Get server templates failed due to {}", e.getMessage(), e); return createCorrectVariant( "Unknown error " + e.getMessage(), headers, Response.Status.INTERNAL_SERVER_ERROR); } }
void processPage(String pageUri) { String search = "href=\""; try { log.info("Calling to Google: " + pageUri); String inputString = UrlUtils.getURL(pageUri); log.info(inputString); int next = 0; Pattern cite = Pattern.compile("<cite>(.*?)</cite>"); Matcher matcher = cite.matcher(inputString); while (matcher.find()) { String newURI = "http://" + matcher .group(1) .replaceAll("\"", "") .replaceAll("<b>|</b>", "") .replaceAll("[ \\t\\n\\r]+", "") .trim(); log.info(newURI); profiles.addDeviceIfNotAlreadyKnown(newURI); } } catch (Exception e) { log.error(e.toString(), e); System.exit(0); } }
public void actionPerformed(ActionEvent evt) { try { if (m_fileButton.isSelected()) { if (m_fileField.getText().equals("")) { throw new IOException("No filename entered."); } File f = new File(m_fileField.getText()); if (!f.exists()) { throw new IOException("File does not exist."); } file = f; } else { if (m_urlField.getText().equals("")) { throw new IOException("No URL entered."); } File f = File.createTempFile("fedora-ingest-", null); f.deleteOnExit(); try { Administrator.DOWNLOADER.get(m_urlField.getText(), new FileOutputStream(f)); } catch (Exception e) { throw new IOException("Download failed: " + m_urlField.getText()); } url = m_urlField.getText(); file = f; } dispose(); } catch (Exception e) { Administrator.showErrorDialog( Administrator.getDesktop(), "Import Error", e.getMessage(), e); } }
public String getKnownShipperDetails(String locationCode, String shipperId) { Connection connection = null; CallableStatement cStmt = null; ResultSet rs = null; String Code = null; try { connection = getConnection(); cStmt = connection.prepareCall("{? = call ETRANS_UTIL.GETKNOWNSHIPPERSTATUS(?,?,?) }"); cStmt.setString(2, locationCode); cStmt.setString(3, shipperId); cStmt.setString(4, "OPR"); cStmt.registerOutParameter(1, java.sql.Types.VARCHAR); cStmt.execute(); Code = cStmt.getString(1); } catch (SQLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { try { ConnectionUtil.closeConnection(connection, cStmt, rs); } catch (Exception ex) { ex.printStackTrace(); } } return Code; }
public static void execute(String[] args) { try { String hs2mmFile = args[0]; HashMap human2mouse = human2mouse(hs2mmFile); String inputFile = args[1]; String outputFile = args[2]; FileWriter fwriter = new FileWriter(outputFile); BufferedWriter out = new BufferedWriter(fwriter); FileInputStream fstream = new FileInputStream(inputFile); DataInputStream din = new DataInputStream(fstream); BufferedReader in = new BufferedReader(new InputStreamReader(din)); while (in.ready()) { String str = in.readLine(); String[] split = str.split("\t"); out.write(split[0] + "\t" + split[1]); for (int i = 2; i < split.length; i++) { if (human2mouse.containsKey(split[i])) { out.write("\t" + (String) human2mouse.get(split[i])); } } out.write("\n"); } in.close(); out.close(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void updatePRICE_nNO(int change_PRICE, int need_orderproductNO) throws Exception { Connection conn = null; PreparedStatement pstmt = null; try { conn = getConnection(); pstmt = conn.prepareStatement( "UPDATE " + "ORDER_PRODUCT " + "SET OP_PRICE=? " + "WHERE OP_NO=?"); pstmt.setInt(1, change_PRICE); pstmt.setInt(2, need_orderproductNO); pstmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { if (pstmt != null) try { pstmt.close(); } catch (SQLException se) { } if (conn != null) try { conn.close(); } catch (SQLException se) { } } }
@POST @Path(PATH_RELATIONSHIP_EXTENSION_METHOD) public Response invokeRelationshipExtension( @PathParam("name") String name, @PathParam("method") String method, @PathParam("relationshipId") long relationshipId, String data) { try { return output.ok( this.invokeRelationshipExtension( relationshipId, name, method, input.readParameterList(data))); } catch (RelationshipNotFoundException e) { return output.notFound(e); } catch (BadInputException e) { return output.badRequest(e); } catch (PluginLookupException e) { return output.notFound(e); } catch (BadPluginInvocationException e) { return output.badRequest(e.getCause()); } catch (PluginInvocationFailureException e) { return output.serverError(e.getCause()); } catch (Exception e) { return output.serverError(e.getCause()); } }
@Override public void propertyChange(PropertyChangeEvent evt) { LOG.debug("propertyChange"); try { if (evt instanceof TURLsArrivedEvent) { TURLsArrivedEvent tae = (TURLsArrivedEvent) evt; String SURL = tae.getSURL(); String TURL = tae.getTURL(); String remoteRequestId = tae.getRequestId(); String remoteFileId = tae.getFileRequestId(); Long size = tae.getSize(); turlArrived(SURL, TURL, remoteRequestId, remoteFileId, size); } else if (evt instanceof TURLsGetFailedEvent) { TURLsGetFailedEvent tgfe = (TURLsGetFailedEvent) evt; String SURL = tgfe.getSURL(); String reason = tgfe.getReason(); String remoteRequestId = tgfe.getRequestId(); String remoteFileId = tgfe.getFileRequestId(); turlRetrievalFailed(SURL, reason, remoteRequestId, remoteFileId); } else if (evt instanceof RequestFailedEvent) { RequestFailedEvent rfe = (RequestFailedEvent) evt; Object reason = rfe.getReason(); turlsRetrievalFailed(reason); } } catch (Exception e) { LOG.error(e.toString()); } }
private void makeQosReservation(int fileIndex) throws MalformedURLException, SRMException { try { CopyFileRequest cfr = getFileRequests().get(fileIndex); RequestCredential credential = RequestCredential.getRequestCredential(credentialId); QOSTicket qosTicket = getQosPlugin() .createTicket( credential.getCredentialName(), getStorage().getFileMetaData(getUser(), cfr.getSourceSurl(), false).size, cfr.getSourceSurl().toASCIIString(), cfr.getSourceSurl().getPort(), cfr.getSourceSurl().getPort(), cfr.getSourceSurl().getScheme(), cfr.getDestinationSurl().toASCIIString(), cfr.getDestinationSurl().getPort(), cfr.getDestinationSurl().getPort(), cfr.getDestinationSurl().getScheme()); getQosPlugin().addTicket(qosTicket); if (getQosPlugin().submit()) { cfr.setQOSTicket(qosTicket); LOG.debug("QOS Ticket Received {}", getQosPlugin()); } } catch (Exception e) { LOG.error("Could not create QOS reservation: {}", e.getMessage()); } }
protected String getPrefix(File cwd, String path) { try { InputStream input = new FileInputStream(Util.makePath(cwd, path)); InputStreamReader inputReader = new InputStreamReader(input); BufferedReader reader = new BufferedReader(inputReader); for (; ; ) { String line = reader.readLine(); if (line == null) break; else line = line.trim(); if (!line.startsWith("package ")) continue; line = line.substring(8); if (line.endsWith(";")) line = line.substring(0, line.length() - 1); line = line.replace(".", "/"); int slash = path.lastIndexOf("/"); int backslash = path.lastIndexOf("\\"); if (backslash > slash) slash = backslash; if (path.endsWith(line + path.substring(slash))) return path.substring(0, path.length() - line.length() - path.length() + slash); } int slash = path.lastIndexOf('/'); return path.substring(0, slash + 1); } catch (Exception e) { e.printStackTrace(); return null; } }
/* * 备注:平台编写规则类 * 接口执行类 */ public Object runComClass(PfParameterVO vo) throws BusinessException { try { super.m_tmpVo = vo; // ####本脚本必须含有返回值,返回DLG和PNL的组件不允许有返回值#### Object retObj = null; // ####该组件为单动作弃审处理开始...不能进行修改#### boolean isFinishToGoing = procUnApproveFlow(vo); // ###返回值:true-审批流程由完成态返回到运行态;false-其他情况 // ####该组件为单动作弃审处理结束...不能进行修改#### if (isFinishToGoing) { // 审批流程由完成态返回到运行态,需要进行的业务补偿 } // ####重要说明:生成的业务组件方法尽量不要进行修改#### // 方法说明:反查单据主表VO的ts属性 retObj = runClass( "nc.bs.trade.business.HYPubBO", "setBillTs", "nc.vo.pub.AggregatedValueObject:01", vo, m_keyHas, m_methodReturnHas); // ################################################## return getVo(); } catch (Exception ex) { if (ex instanceof BusinessException) throw (BusinessException) ex; else throw new PFBusinessException(ex.getMessage(), ex); } }
/** this void method runs the command created in the constructor. */ public void runTesseract() { LOGGER.info( "Trying to run command: " + command[0] + " " + command[1] + " " + command[2] + " " + command[3] + " " + command[4]); System.out.println("Trying to run command: " + Arrays.toString(command)); try { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line; while ((line = input.readLine()) != null) { System.out.println(line); } int exitVal = pr.waitFor(); System.out.println("Exited with error code " + exitVal); } catch (Exception e) { System.out.println(e.toString()); e.printStackTrace(); } }
/** @param args */ public static void main(String[] args) { Properties props = new Properties(System.getProperties()); props.setProperty("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory"); props.setProperty("java.naming.security.authentication", "simple"); // props.setProperty( "java.naming.provider.url", "ldap://bowmore.dev.ksi.co.jp:50389/" ); // props.setProperty( "java.naming.security.principal", "cn=Directory Manager" ); // props.setProperty( "java.naming.security.credentials", "amAdmin25" ); props.setProperty("java.naming.provider.url", "ldap://fscs1.ap.ksi.co.jp/"); // props.setProperty( "java.naming.security.principal", "cn=Directory Manager" ); // props.setProperty( "java.naming.security.credentials", "amAdmin25" ); String base = "OU=User,OU=Account,DC=oa,DC=ksi,DC=co,DC=jp"; String searchText = "(objectClass=*)"; int scope = LdapManager.ONELEVEL_SCOPE; LdapManager ldap = new LdapManager(); try { ldap = new LdapManager(props); System.out.println("baseDN=" + ldap.getBaseDN()); ldap.searchEntry(base, searchText, scope); } catch (Exception e) { e.printStackTrace(); } finally { ldap.close(); } }
@Test public void testLargeMeanCumulativeProbability() { double mean = 1.0; while (mean <= 10000000.0) { PoissonDistribution dist = new PoissonDistribution(mean); double x = mean * 2.0; double dx = x / 10.0; double p = Double.NaN; double sigma = FastMath.sqrt(mean); while (x >= 0) { try { p = dist.cumulativeProbability((int) x); Assert.assertFalse( "NaN cumulative probability returned for mean = " + mean + " x = " + x, Double.isNaN(p)); if (x > mean - 2 * sigma) { Assert.assertTrue( "Zero cum probaility returned for mean = " + mean + " x = " + x, p > 0); } } catch (Exception ex) { Assert.fail("mean of " + mean + " and x of " + x + " caused " + ex.getMessage()); } x -= dx; } mean *= 10.0; } }
/** * A convenient method for view the ASpace json records. It meant to be used for development * purposes only */ private void viewRecordButtonActionPerformed() { String uri = recordURIComboBox.getSelectedItem().toString(); String recordJSON = ""; try { if (aspaceClient == null) { String host = hostTextField.getText().trim(); String admin = adminTextField.getText(); String adminPassword = adminPasswordTextField.getText(); aspaceClient = new ASpaceClient(host, admin, adminPassword); aspaceClient.getSession(); } recordJSON = aspaceClient.getRecordAsJSONString(uri, paramsTextField.getText()); if (recordJSON == null || recordJSON.isEmpty()) { recordJSON = aspaceClient.getErrorMessages(); } } catch (Exception e) { recordJSON = e.toString(); } CodeViewerDialog codeViewerDialog = new CodeViewerDialog(this, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, recordJSON, true, true); codeViewerDialog.setTitle("REST ENDPOINT URI: " + uri); codeViewerDialog.pack(); codeViewerDialog.setVisible(true); }
public static void main(String[] args) { try { new SassCompiler(args); } catch (Exception e) { e.printStackTrace(); } }
public static String getFormattedDateTime( String sDay, String sMonth, String sYear, String sHour, String sMin, String sSec, String sMillisec, String sDateTimeFormatType) throws Exception { String sFormattedDT = ""; try { String sTmpFormattedDT = ""; if (sDateTimeFormatType.equals("DTF_DEC")) { sTmpFormattedDT += sYear + "-"; sTmpFormattedDT += sMonth + "-"; sTmpFormattedDT += sDay + "T"; sTmpFormattedDT += sHour + ":"; sTmpFormattedDT += sMin + ":"; sTmpFormattedDT += sSec + "."; sTmpFormattedDT += sMillisec; } sFormattedDT = sTmpFormattedDT; } catch (Exception e) { mLogger.error( "Component CM perform operation getCurrentDateTime. It has not been executed correctly. Exception: " + e.getMessage() + "."); } return sFormattedDT; }
@Override public Revision commit(CommitRequest request) throws GitException { ensureExistenceRepoRootInWorkingDirectory(); CommitCommand command = nativeGit.createCommitCommand(); GitUser committer = getLocalCommitter(); command.setCommitter(committer); try { // overrider author from .gitconfig. We may set it in previous versions. // We need to override it since committer can differ from the person who clone or init // repository. getConfig().get("user.name"); command.setAuthor(committer); } catch (GitException e) { // ignore property not found. } command.setAll(request.isAll()); command.setAmend(request.isAmend()); command.setMessage(request.getMessage()); command.setFiles(request.getFiles()); try { command.execute(); LogCommand log = nativeGit.createLogCommand(); Revision rev = log.execute().get(0); rev.setBranch(getCurrentBranch()); return rev; } catch (Exception e) { Revision revision = DtoFactory.getInstance().createDto(Revision.class); revision.setMessage(e.getMessage()); revision.setFake(true); return revision; } }
public PartyLovDAO() { try { dataSource = LookUpBean.getDataSource(); } catch (Exception nmEx) { nmEx.printStackTrace(); } }
@Override public void deleteOrderProduct(OrderProductDTO orderproduct) throws Exception { Connection conn = null; PreparedStatement pstmt = null; try { conn = getConnection(); pstmt = conn.prepareStatement("DELETE FROM ORDER_PRODUCT WHERE OP_NO=?"); pstmt.setInt(1, orderproduct.getOP_no()); pstmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { if (pstmt != null) try { pstmt.close(); } catch (SQLException se) { } if (conn != null) try { conn.close(); } catch (SQLException se) { } } }
/** * Set the value of an element (when edited by hand). * * @param oValue the new value. * @param row the new value row. * @param column the new value column. */ public void setValueAt(Object oValue, int row, int column) { if (column == 0) { return; } try { double value = 0.0; // oValue can be String or a Number. if (oValue instanceof String) { value = AstDouble.parseDouble((String) oValue, plot.getMapping(), 1); } else if (oValue instanceof Number) { value = ((Number) oValue).doubleValue(); } XGraphicsRange xRange = (XGraphicsRange) rangeObjects.get(row); double[] range = xRange.getRange(); if (column == 1) { range[0] = value; } else { range[1] = value; } xRange.setRange(range); } catch (Exception e) { e.printStackTrace(); } }
/* input defaults to reading the Fakefile, cwd to "." */ public void make(InputStream input, File cwd, String[] args) { try { Parser parser = parse(input, cwd); // filter out variable definitions int firstArg = 0; while (firstArg < args.length && args[firstArg].indexOf('=') >= 0) firstArg++; List<String> list = null; if (args.length > firstArg) { list = new ArrayList<String>(); for (int i = firstArg; i < args.length; i++) list.add(args[i]); } Rule all = parser.parseRules(list); for (int i = 0; i < firstArg; i++) { int equal = args[i].indexOf('='); parser.setVariable(args[i].substring(0, equal), args[i].substring(equal + 1)); } for (Rule rule : all.getDependenciesRecursively()) if (rule.getVarBool("rebuild")) rule.clean(false); String parallel = all.getVar("parallel"); if (parallel != null) all.makeParallel(Integer.parseInt(parallel)); else all.make(); } catch (FakeException e) { System.err.println(e); System.exit(1); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
public ArrayList get2DImageDataList(String urlString, ArrayList list) { try { ReadXML readXML = new ReadXML(); System.out.println("************************URLString is******************* - " + urlString); String xmlString = readXML.convertFromURLToString(urlString); System.out.println("XMLString is - " + xmlString); list = readXML.getImageData(xmlString); System.out.println("List Size is - " + list.size()); Iterator iterator = list.iterator(); /* CentralServiceVO vo = null; while (iterator.hasNext()) { vo = (CentralServiceVO)iterator.next(); //System.out.println("URL = "+vo.getWms()); //System.out.println("TFW Values = "+vo.getTfwValues()); } */ } catch (Exception e) { e.printStackTrace(); } return list; }
@POST @Path("servers/{id}/containers/{containerId}/status/started") @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public Response startContainer( @Context HttpHeaders headers, @PathParam("id") String serverTemplateId, @PathParam("containerId") String containerId) { logger.debug( "Requesting start container with id {} server instance: {}", containerId, serverTemplateId); try { ContainerSpecKey containerSpecKey = new ContainerSpecKey(); containerSpecKey.setId(containerId); containerSpecKey.setServerTemplateKey(new ServerTemplateKey(serverTemplateId, "")); super.startContainer(containerSpecKey); logger.debug( "Returning response for start container with id {} server instance: {}", containerId, serverTemplateId); return createCorrectVariant("", headers, Response.Status.OK); } catch (KieServerControllerNotFoundException e) { return createCorrectVariant(e.getMessage(), headers, Response.Status.NOT_FOUND); } catch (Exception e) { logger.error("Start container failed due to {}", e.getMessage(), e); return createCorrectVariant( "Unknown error " + e.getMessage(), headers, Response.Status.INTERNAL_SERVER_ERROR); } }
public ArrayList getStructureData(String urlString, ArrayList list) { KeyValueBean keyValue = new KeyValueBean(); Element xmlElement = null; try { System.out.println("1"); ReadXML readXML = new ReadXML(); System.out.println("2"); String xmlString = readXML.convertFromURLToString(urlString); System.out.println("3"); xmlElement = readXML.getDocumentElementFromString(xmlString); System.out.println("9"); keyValue.setKey(readXML.getStringValueForXMLTag(xmlElement, "Code")); System.out.println("10"); keyValue.setValue(readXML.getStringValueForXMLTag(xmlElement, "Description")); System.out.println("11"); list.add(keyValue); } catch (Exception e) { e.printStackTrace(); } finally { xmlElement = null; } return list; }
/** * Show the specified wizard page * * @param index */ private void showPage(Integer index, Direction dir) { AbstractWizardPanel page; try { page = pages.get(index); } catch (Exception e) { log.error("Error setting wizard page to index: " + index); e.printStackTrace(); return; } // Check to see if page should be ignored if (isIgnoredPageClass(page)) { if (dir.equals(Direction.FORWARD)) { index++; } else { index--; } showPage(index, dir); return; } pagePanel.removeAll(); pagePanel.add(page); lblTitle.setText(page.getTitle()); txtInstructions.setText(page.getInstructions()); currPageIndex = index; autoEnableNavButtons(); page.initialViewTasks(); pagePanel.repaint(); }
/** Sends email asynchronously through Sendgrid. */ @Override @Async public void sendEmail(final EmailMessage message) { if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) { return; } SendGrid sendgrid = new SendGrid(username, password); sendgrid.setFrom(message.getFromEmail()); sendgrid.setFromName(message.getFromName()); sendgrid.addTo(message.getToEmail()); sendgrid.addToName(message.getToName()); sendgrid.setReplyTo(message.getReplyTo()); sendgrid.setSubject(message.getSubject()); sendgrid.setText(message.getBody()); try { LOGGER.info( "Try to send email to {}, message is: {}", message.getToEmail(), message.getBody()); String response = sendgrid.send(); LOGGER.info("Sent email successfully, response from SendGrid is: {}", response); } catch (Exception ex) { LOGGER.debug("Exception:", ex); LOGGER.error("Got exception when sending email through sendgrid: {}", ex.getMessage()); } }