List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:org.hawkular.alerts.actions.sms.SmsPlugin.java
void setup() { if (StringUtils.isBlank(ACCOUNT_SID) || StringUtils.isBlank(AUTH_TOKEN)) { String msg = "Configure " + ACCOUNT_SID_PROPERTY + " and " + AUTH_TOKEN_PROPERTY; msgLog.errorCannotBeStarted("sms", msg); return;/* ww w. ja va 2 s. c o m*/ } try { TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); Account account = client.getAccount(); messageFactory = account.getMessageFactory(); } catch (Exception e) { msgLog.errorCannotBeStarted("sms", e.getLocalizedMessage()); } }
From source file:com.kylinolap.job.hadoop.invertedindex.IICreateHTableJob.java
@Override public int run(String[] args) throws Exception { Options options = new Options(); try {//from ww w . j av a2s .c o m options.addOption(OPTION_CUBE_NAME); options.addOption(OPTION_PARTITION_FILE_PATH); options.addOption(OPTION_HTABLE_NAME); parseOptions(options, args); Path partitionFilePath = new Path(getOptionValue(OPTION_PARTITION_FILE_PATH)); String tableName = getOptionValue(OPTION_HTABLE_NAME); HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName)); HColumnDescriptor cf = new HColumnDescriptor(InvertedIndexDesc.HBASE_FAMILY); cf.setMaxVersions(1); cf.setCompressionType(Algorithm.LZO); cf.setDataBlockEncoding(DataBlockEncoding.FAST_DIFF); tableDesc.addFamily(cf); Configuration conf = HBaseConfiguration.create(getConf()); if (User.isHBaseSecurityEnabled(conf)) { // add coprocessor for bulk load tableDesc.addCoprocessor("org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint"); } // drop the table first HBaseAdmin admin = new HBaseAdmin(conf); if (admin.tableExists(tableName)) { admin.disableTable(tableName); admin.deleteTable(tableName); } // create table byte[][] splitKeys = getSplits(conf, partitionFilePath); if (splitKeys.length == 0) splitKeys = null; admin.createTable(tableDesc, splitKeys); if (splitKeys != null) { for (int i = 0; i < splitKeys.length; i++) { System.out.println("split key " + i + ": " + BytesUtil.toHex(splitKeys[i])); } } System.out.println("create hbase table " + tableName + " done."); admin.close(); return 0; } catch (Exception e) { printUsage(options); e.printStackTrace(System.err); log.error(e.getLocalizedMessage(), e); return 2; } }
From source file:com.serena.rlc.provider.filesystem.client.FilesystemClient.java
public void localExec(String execScript, String execDir, String execParams, boolean ignoreErrors) throws FilesystemClientException { Path script = Paths.get(execDir + File.separatorChar + execScript); try {//from w w w. j av a2 s . c o m if (!Files.exists(script)) { if (ignoreErrors) { logger.debug("Execution script " + script.toString() + " does not exist, ignoring..."); } else { throw new FilesystemClientException( "Execution script " + script.toString() + " does not exist"); } } else { ProcessBuilder pb = new ProcessBuilder(script.toString()); pb.directory(new File(script.getParent().toString())); System.out.println(pb.directory().toString()); logger.debug("Executing script " + execScript + " in directory " + execDir + " with parameters: " + execParams); Process p = pb.start(); // Start the process. p.waitFor(); // Wait for the process to finish. logger.debug("Executed script " + execScript + " successfully."); } } catch (Exception e) { logger.debug(e.getLocalizedMessage()); throw new FilesystemClientException(e.getLocalizedMessage()); } }
From source file:it.geosolutions.opensdi.operations.AbstractOperationController.java
/** * This method could be redefined to allow less operations that needed on getJsp method. * For example, you can @see {@link FileBrowserOperationController#getRestResponse(ModelMap, HttpServletRequest, List)} * /* ww w . ja v a 2 s .c o m*/ * @return the JSON response on file upload */ public Map<String, Object> getRestResponse(ModelMap model, HttpServletRequest request, List<File> files) { Map<String, Object> response = new HashMap<String, Object>(); try { response.put(ControllerUtils.SUCCESS, true); response.put(ControllerUtils.ROOT, getJsp(model, request, files)); } catch (Exception e) { LOGGER.error("Error uploading files", e); response.put(ControllerUtils.SUCCESS, false); response.put(ControllerUtils.ROOT, e.getLocalizedMessage()); } return response; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectOtherIdentifiersListener.java
@Override public void handleEvent(Event event) { //write in a new file File file = new File(this.dataType.getPath().toString() + File.separator + this.dataType.getStudy().toString() + ".columns.tmp"); try {/*from w ww.jav a 2 s .co m*/ FileWriter fw = new FileWriter(file); BufferedWriter out = new BufferedWriter(fw); out.write( "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n"); //subject identifier Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles(); Vector<String> siteIds = this.setOtherIdsUI.getSiteIds(); Vector<String> visitNames = this.setOtherIdsUI.getVisitNames(); for (int i = 0; i < rawFiles.size(); i++) { //site identifier if (siteIds.elementAt(i).compareTo("") != 0) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), siteIds.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSITE_ID\t\t\n"); } } //visit name if (visitNames.elementAt(i).compareTo("") != 0) { int columnNumber = FileHandler.getHeaderNumber(rawFiles.elementAt(i), visitNames.elementAt(i)); if (columnNumber != -1) { out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tVISIT_NAME\t\t\n"); } } } try { BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF())); String line = br.readLine(); while ((line = br.readLine()) != null) { String[] s = line.split("\t", -1); if (s[3].compareTo("SITE_ID") != 0 && s[3].compareTo("VISIT_NAME") != 0) { out.write(line + "\n"); } } br.close(); } catch (Exception e) { this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); out.close(); } out.close(); try { String fileName = ((ClinicalData) this.dataType).getCMF().getName(); ((ClinicalData) this.dataType).getCMF().delete(); File fileDest = new File(this.dataType.getPath() + File.separator + fileName); FileUtils.moveFile(file, fileDest); ((ClinicalData) this.dataType).setCMF(fileDest); } catch (IOException ioe) { this.setOtherIdsUI.displayMessage("File error: " + ioe.getLocalizedMessage()); return; } } catch (Exception e) { this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } this.setOtherIdsUI.displayMessage("Column mapping file updated"); WorkPart.updateSteps(); WorkPart.updateFiles(); UsedFilesPart.sendFilesChanged(dataType); }
From source file:org.apache.juneau.rest.client.RestCallException.java
/** * Constructor./*from ww w .j a v a 2 s . c om*/ * * @param e The inner cause of the exception. */ public RestCallException(Exception e) { super(e.getLocalizedMessage(), e); if (e instanceof FileNotFoundException) { responseCode = 404; } else if (e.getMessage() != null) { Pattern p = Pattern.compile("[^\\d](\\d{3})[^\\d]"); Matcher m = p.matcher(e.getMessage()); if (m.find()) responseCode = Integer.parseInt(m.group(1)); } setStackTrace(e.getStackTrace()); }
From source file:com.anrisoftware.prefdialog.appdialogs.dialogheader.HeaderLogoLogger.java
RuntimeException errorScaleImage(HeaderLogo header, Exception e) { return logException(new ContextedRuntimeException(error_scale_header_logo_image.toString(), e), error_scale_header_logo_image_message.toString(), e.getLocalizedMessage()); }
From source file:com.ibm.rpe.web.service.docgen.servlet.XmlToJSON.java
@GET @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) public Response convertXmlToJson(@Context HttpServletRequest request, @QueryParam("url") String xmlUrl) throws Exception { try {/*from w ww . j a va 2 s .c om*/ Client client = new Client(); WebResource service = client.resource(UriBuilder.fromUri(xmlUrl).build()); ClientResponse clientResponse = service.accept(MediaType.APPLICATION_XML).get(ClientResponse.class); if (Response.Status.OK.getStatusCode() != clientResponse.getStatus()) { return Response.serverError().status(Status.BAD_REQUEST) .entity(clientResponse.getEntity(String.class)).build(); } InputStream xmlStream = clientResponse.getEntityInputStream(); String xmlAsString = IOUtils.toString(xmlStream, "UTF-8"); return Response.ok().entity(getXMLfromJson(xmlAsString)).build(); } catch (Exception e) { e.printStackTrace(); return Response.serverError().status(Status.BAD_REQUEST) .entity(JSONUtils.writeValue(e.getLocalizedMessage())).build(); } }
From source file:com.wso2.stream.connector.protocol.TwitterProcessor.java
public void start() { log.info("Inbound Twitter listener Started for destination " + name); try {// www . j a va 2s . c o m Task task = new TwitterTask(pollingConsumer); TaskDescription taskDescription = new TaskDescription(); taskDescription.setName(name + "-TWITTER-EP"); taskDescription.setTaskGroup("TWITTER-EP"); taskDescription.setInterval(interval); taskDescription.setIntervalInMs(true); taskDescription.addResource(TaskDescription.INSTANCE, task); taskDescription.addResource(TaskDescription.CLASSNAME, task.getClass().getName()); startUpController = new StartUpController(); startUpController.setTaskDescription(taskDescription); startUpController.init(synapseEnvironment); } catch (Exception e) { log.error("Could not start Twitter Processor. Error starting up scheduler. Error: " + e.getLocalizedMessage()); } }
From source file:org.metis.cassandra.MatchingTest.java
@Test public void TestA() { list.clear();//w ww . ja v a 2 s . c o m map.clear(); list.add("select * from users"); list.add("select username, created_date from users where username = `ascii:username`"); list.add( "select videoid, username from video_event where videoid=`uuid:videoid` and username=`ascii:username`"); client = new Client(); client.setCqls4Select(list); client.setClusterBean(clusterBean); client.setKeyspace("videodb"); try { client.afterPropertiesSet(); } catch (Exception e) { e.printStackTrace(); fail("ERROR: got this Exception: " + e.getLocalizedMessage()); } cqlList = client.getCqlStmnts4Select(); assertTrue(cqlList != null); assertTrue(cqlList.get(0).getNumKeyTokens() == 0); assertTrue(cqlList.get(1).getNumKeyTokens() == 1); assertTrue(cqlList.get(2).getNumKeyTokens() == 2); assertFalse(cqlList.get(0).isPrepared()); assertTrue(cqlList.get(1).isPrepared()); assertTrue(cqlList.get(2).isPrepared()); CqlStmnt stmnt = CqlStmnt.getMatch(cqlList, map.keySet()); assertTrue(stmnt != null); assertTrue("select * from users".equals(stmnt.getOriginalStr())); map.put("username", "joef551"); stmnt = CqlStmnt.getMatch(cqlList, map.keySet()); assertTrue(stmnt != null); assertTrue("select username , created_date from users where username = ?".equals(stmnt.getPreparedStr())); map.put("videoid", "3984793"); stmnt = CqlStmnt.getMatch(cqlList, map.keySet()); assertTrue(stmnt != null); assertTrue("select videoid , username from video_event where videoid= ? and username= ?" .equals(stmnt.getPreparedStr())); map.put("foobar", "3984793"); stmnt = CqlStmnt.getMatch(cqlList, map.keySet()); assertTrue(stmnt == null); map.clear(); map.put("foo", "joef551"); stmnt = CqlStmnt.getMatch(cqlList, map.keySet()); assertTrue(stmnt == null); }