List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:com.streamsets.pipeline.stage.origin.tcp.TestTCPServerSource.java
@Test public void errorHandling() throws StageException, IOException, ExecutionException, InterruptedException { final Charset charset = Charsets.ISO_8859_1; final TCPServerSourceConfig configBean = createConfigBean(charset); configBean.dataFormat = DataFormat.JSON; configBean.tcpMode = TCPMode.DELIMITED_RECORDS; configBean.recordSeparatorStr = "\n"; configBean.ports = NetworkUtils.getRandomPorts(1); final TCPServerSource source = new TCPServerSource(configBean); final String outputLane = "lane"; final PushSourceRunner toErrorRunner = new PushSourceRunner.Builder(TCPServerDSource.class, source) .addOutputLane(outputLane).setOnRecordError(OnRecordError.TO_ERROR).build(); final List<Record> records = new LinkedList<>(); final List<Record> errorRecords = new LinkedList<>(); runAndCollectRecords(toErrorRunner, configBean, records, errorRecords, 1, outputLane, "{\"invalid_json\": yes}\n".getBytes(charset), true, false); assertThat(records, empty());//from www .j a va2 s. c om assertThat(errorRecords, hasSize(1)); assertThat(errorRecords.get(0).getHeader().getErrorCode(), equalTo(com.streamsets.pipeline.lib.parser.Errors.DATA_PARSER_04.getCode())); final PushSourceRunner discardRunner = new PushSourceRunner.Builder(TCPServerDSource.class, source) .addOutputLane(outputLane).setOnRecordError(OnRecordError.DISCARD).build(); records.clear(); errorRecords.clear(); configBean.ports = NetworkUtils.getRandomPorts(1); runAndCollectRecords(discardRunner, configBean, records, errorRecords, 1, outputLane, "{\"invalid_json\": yes}\n".getBytes(charset), true, false); assertThat(records, empty()); assertThat(errorRecords, empty()); configBean.ports = NetworkUtils.getRandomPorts(1); final PushSourceRunner stopPipelineRunner = new PushSourceRunner.Builder(TCPServerDSource.class, source) .addOutputLane(outputLane).setOnRecordError(OnRecordError.STOP_PIPELINE).build(); records.clear(); errorRecords.clear(); try { runAndCollectRecords(stopPipelineRunner, configBean, records, errorRecords, 1, outputLane, "{\"invalid_json\": yes}\n".getBytes(charset), true, true); Assert.fail("ExecutionException should have been thrown"); } catch (ExecutionException e) { assertThat(e.getCause(), instanceOf(RuntimeException.class)); final RuntimeException runtimeException = (RuntimeException) e.getCause(); assertThat(runtimeException.getCause(), instanceOf(StageException.class)); final StageException stageException = (StageException) runtimeException.getCause(); assertThat(stageException.getErrorCode().getCode(), equalTo(Errors.TCP_06.getCode())); } }
From source file:com.enioka.jqm.tools.Loader.java
private void endBlockDbFailureAnalysis(RuntimeException e) { if (Helpers.testDbFailure(e)) { jqmlogger.error(/*from ww w . j av a2 s .c o m*/ "connection to database lost - loader " + this.getId() + " will need delayed finalization"); jqmlogger.trace("connection error was:", e.getCause()); this.engine.loaderFinalizationNeeded(this); this.isDelayed = true; } else { jqmlogger.error("a database related operation has failed and cannot be recovered"); throw e; } }
From source file:com.aliyun.odps.volume.VolumeFSClient.java
/** * List files (and directories) in specific path * // w ww . j ava 2s . com * @param path * @throws VolumeException */ public VolumeFSFile[] getFileInfosByPath(String path) throws VolumeException { return new VolumeFSJobRunnerProxy<VolumeFSFile[]>() { @Override public VolumeFSFile[] doJob(String path, Map<String, Object> params) throws VolumeException { VolumeFSFile file = odps.volumes().get(VolumeFSUtil.getVolumeFromPath(path)).getVolumeFSFile(path); Iterator<VolumeFSFile> iterator = file.iterator(); List<VolumeFSFile> files = new ArrayList<VolumeFSFile>(); try { while (iterator.hasNext()) { files.add(iterator.next()); } } catch (RuntimeException e) { if (e.getCause() instanceof VolumeException) { throw (VolumeException) e.getCause(); } else { throw new VolumeException(e); } } return files.toArray(new VolumeFSFile[0]); } @Override public VolumeFSFile[] onVolumeMissing(String path, Map<String, Object> params) throws VolumeException { List<VolumeFSFile> files = new ArrayList<VolumeFSFile>(); Volumes volumes = odps.volumes(); Iterator<Volume> it = volumes.iterator(); while (it.hasNext()) { Volume v = it.next(); if (isNewVolume(v)) { files.add(VolumeFSFile.transferVolumeToVolumeFSFile(odps.getDefaultProject(), v, odps.getRestClient())); } } return files.toArray(new VolumeFSFile[0]); } @Override public VolumeFSFile[] onNoSuchVolume(String path, Map<String, Object> params) throws VolumeException { throw new VolumeException(VolumeFSErrorCode.NoSuchPath, VolumeFSErrorMessageGenerator.noSuchFileOrDirectory(path)); } @Override public VolumeFSFile[] onInvalidPath(String path, Map<String, Object> params) throws VolumeException { if (VolumeFSUtil.checkPathIsJustVolume(path)) { return doJob(path, params); } else { throw (VolumeException) params.get(CUR_EXCEPTION); } } }.run(path, null); }
From source file:com.clustercontrol.jobmanagement.util.SendApprovalMail.java
/** * ?????/*from w w w. j av a 2 s .c om*/ * * @param jobInfo * * @param subject * ?? * @param content * */ private void sendMail(JobInfoEntity jobInfo, String subject, String content, String approvalRequestUser) throws HinemosUnknown { m_log.debug("sendMail()"); m_log.debug("sendMail() subject:" + subject); m_log.debug("sendMail() content:" + content); try { ArrayList<String> toAddressList = new ArrayList<String>(); String userId = null; List<String> userIdList = null; String addr; userId = jobInfo.getApprovalReqUserId(); if (userId != null && !userId.equals("*")) { addr = getUserMailAdress(userId); if (addr != null) { toAddressList.add(addr); } } else { userIdList = UserRoleCache.getUserIdList(jobInfo.getApprovalReqRoleId()); if (userIdList != null && !userIdList.isEmpty()) { for (String user : userIdList) { addr = null; addr = getUserMailAdress(user); if (addr != null) { toAddressList.add(addr); } } } } if (approvalRequestUser != null && !approvalRequestUser.equals("")) { addr = null; addr = getUserMailAdress(approvalRequestUser); if (addr != null) { toAddressList.add(addr); } } // ???????? if (toAddressList.size() == 0) { m_log.debug("sendMail() : mail address is empty"); internalEventNotify(PriorityConstant.TYPE_INFO, jobInfo.getId().getSessionId(), jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_019_JOB, null); return; } String[] toAddress = toAddressList.toArray(new String[0]); try { this.sendMail(toAddress, null, subject, content); } catch (AuthenticationFailedException e) { String detailMsg = "cannot connect to the mail server due to an Authentication Failure"; m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + " : " + e.getClass().getSimpleName() + ", " + e.getMessage()); internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(), jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null); } catch (SMTPAddressFailedException e) { String detailMsg = e.getMessage() + "(SMTPAddressFailedException)"; m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + " : " + e.getClass().getSimpleName() + ", " + e.getMessage()); internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(), jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null); } catch (MessagingException e) { String detailMsg = e.getCause() != null ? e.getMessage() + " Cause : " + e.getCause().getMessage() : e.getMessage(); m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + " : " + e.getClass().getSimpleName() + ", " + e.getMessage()); internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(), jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null); } catch (UnsupportedEncodingException e) { String detailMsg = e.getCause() != null ? e.getMessage() + " Cause : " + e.getCause().getMessage() : e.getMessage(); m_log.warn("sendMail() " + e.getMessage() + " : " + detailMsg + detailMsg + " : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(), jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null); } } catch (RuntimeException e1) { String detailMsg = e1.getCause() != null ? e1.getMessage() + " Cause : " + e1.getCause().getMessage() : e1.getMessage(); m_log.warn("sendMail() " + e1.getMessage() + " : " + detailMsg + detailMsg + " : " + e1.getClass().getSimpleName() + ", " + e1.getMessage(), e1); internalEventNotify(PriorityConstant.TYPE_CRITICAL, jobInfo.getId().getSessionId(), jobInfo.getId().getJobId(), MessageConstant.MESSAGE_SYS_020_JOB, null); } }
From source file:com.heliumv.api.BaseApi.java
/** * Ein bewusstes Duplikat von Delegate.handleThrowable im LPClientPC</br> * <p>Traue mich momentan noch nicht drüber das zu refaktoren</p> * /* w ww . j a v a 2 s . co m*/ * @param t * @return */ protected ExceptionLP handleThrowable(Throwable t) { if (t instanceof ExceptionLP) return (ExceptionLP) t; if (t instanceof RuntimeException) { RuntimeException reI = (RuntimeException) t; // Throwable t2 = reI.getCause(); // if (t2 != null && t2 instanceof ServerException) { Throwable t3 = reI.getCause(); if (t3 instanceof EJBExceptionLP) { EJBExceptionLP ejbt4 = (EJBExceptionLP) t3; if (ejbt4 instanceof EJBExceptionLP) { Throwable ejbt5 = ejbt4.getCause(); if (ejbt5 instanceof EJBExceptionLP) { // wegen zB. unique key knaller EJBExceptionLP ejbt6 = (EJBExceptionLP) ejbt5; return new ExceptionLP(ejbt6.getCode(), ejbt6.getMessage(), ejbt6.getAlInfoForTheClient(), ejbt6.getCause()); } else if (ejbt5 != null) { Throwable ejbt7 = ejbt5.getCause(); if (ejbt7 instanceof EJBExceptionLP) { // zB. fuer WARNUNG_KTO_BESETZT EJBExceptionLP ejbt8 = (EJBExceptionLP) ejbt7; return new ExceptionLP(ejbt8.getCode(), ejbt8.getMessage(), ejbt8.getAlInfoForTheClient(), ejbt8.getCause()); } else { return new ExceptionLP(ejbt4.getCode(), ejbt4.getMessage(), ejbt4.getAlInfoForTheClient(), ejbt4.getCause()); } } else { return new ExceptionLP(ejbt4.getCode(), ejbt4.getMessage(), ejbt4.getAlInfoForTheClient(), ejbt4.getCause()); } } } else if (reI instanceof EJBExceptionLP) { EJBExceptionLP exc = (EJBExceptionLP) reI; return new ExceptionLP(exc.getCode(), exc.getMessage(), exc.getAlInfoForTheClient(), exc.getCause()); } else if (t3 instanceof JBossRollbackException) { // zB. unique key knaller. JBossRollbackException ejb = (JBossRollbackException) t3; return new ExceptionLP(EJBExceptionLP.FEHLER_DUPLICATE_UNIQUE, ejb.getMessage(), null, ejb.getCause()); } else if (t3 instanceof EJBExceptionLP) { // MB 13. 03. 06 wird ausgeloest, wenn belegnummern ausserhalb // des gueltigen bereichs generiert werden // (liegt vermutlich am localen interface des BN-Generators) EJBExceptionLP ejbt6 = (EJBExceptionLP) t3; return new ExceptionLP(ejbt6.getCode(), ejbt6.getMessage(), ejbt6.getAlInfoForTheClient(), ejbt6.getCause()); } else if (t3 instanceof java.io.InvalidClassException) { // zB. unique key knaller. java.io.InvalidClassException ejb = (java.io.InvalidClassException) t3; return new ExceptionLP(EJBExceptionLP.FEHLER_BUILD_CLIENT, ejb.getMessage(), null, ejb.getCause()); } else if (t3 instanceof java.lang.NoClassDefFoundError) { // zB. unique key knaller. java.lang.NoClassDefFoundError ejb = (java.lang.NoClassDefFoundError) t3; return new ExceptionLP(EJBExceptionLP.FEHLER_NOCLASSDEFFOUNDERROR, ejb.getMessage(), null, ejb.getCause()); } } if (t instanceof java.lang.IllegalStateException) { return new ExceptionLP(EJBExceptionLP.FEHLER_TRANSACTION_TIMEOUT, t); } if (t != null && t.getCause() != null) { return new ExceptionLP(EJBExceptionLP.FEHLER, t.getMessage(), null, t.getCause()); } if (t != null) { return new ExceptionLP(EJBExceptionLP.FEHLER, t.getMessage(), null, t); } else { return new ExceptionLP(EJBExceptionLP.FEHLER, "null exception", new Exception()); } }
From source file:com.continusec.client.VerifiableLog.java
/** * Utility method for auditors that wish to audit the full content of a log, as well as the log operation. * This method will retrieve all entries in batch from the log, and ensure that the root hash in head can be confirmed to accurately represent the contents * of all of the log entries. If prev is not null, then additionally it is proven that the root hash in head is consistent with the root hash in prev. * @param prev a previous LogTreeHead representing the set of entries that have been previously audited. To indicate this is has not previously been audited, pass null, * @param head the LogTreeHead up to which we wish to audit the log. Upon successful completion the caller should persist this for a future iteration. * @param auditor caller should implemented a LogAuditor which is called sequentially for each log entry as it is encountered. * @param factory the factory to use for instantiating log entries. Typically this is one of {@link RawDataEntryFactory#getInstance()}, {@link JsonEntryFactory#getInstance()}, {@link RedactedJsonEntryFactory#getInstance()}. * @throws ContinusecException upon error *///from ww w . j av a 2 s. co m public void verifyEntries(LogTreeHead prev, LogTreeHead head, VerifiableEntryFactory factory, LogAuditor auditor) throws ContinusecException { if ((prev == null) || prev.getTreeSize() < head.getTreeSize()) { Stack<byte[]> merkleTreeStack = new Stack<byte[]>(); if ((prev != null) && (prev.getTreeSize() > 0)) { LogInclusionProof p = this.getInclusionProofByIndex(prev.getTreeSize() + 1, prev.getTreeSize()); byte[] firstHash = null; for (byte[] b : p.getAuditPath()) { if (firstHash == null) { firstHash = b; } else { firstHash = Util.nodeMerkleTreeHash(b, firstHash); } } if (!(Arrays.equals(firstHash, prev.getRootHash()))) { throw new VerificationFailedException(); } for (int i = p.getAuditPath().length - 1; i >= 0; i--) { merkleTreeStack.push(p.getAuditPath()[i]); } } int idx = (prev == null) ? 0 : prev.getTreeSize(); try { for (VerifiableEntry e : this.getEntries(idx, head.getTreeSize(), factory)) { // do whatever content audit is desired on e auditor.auditLogEntry(idx, e); // update the merkle tree hash stack: merkleTreeStack.add(e.getLeafHash()); for (int z = idx; (z & 1) == 1; z >>= 1) { byte[] right = merkleTreeStack.pop(); byte[] left = merkleTreeStack.pop(); merkleTreeStack.push(Util.nodeMerkleTreeHash(left, right)); } idx++; } } catch (RuntimeException e2) { // since get entries iterator throws a runtime exception that wraps the real continusec exception... Throwable cause = e2.getCause(); if (cause instanceof ContinusecException) { throw (ContinusecException) cause; } else { throw e2; } } if (idx != head.getTreeSize()) { throw new NotAllEntriesReturnedException(); } byte[] headHash = merkleTreeStack.pop(); while (!merkleTreeStack.empty()) { headHash = Util.nodeMerkleTreeHash(merkleTreeStack.pop(), headHash); } if (!(Arrays.equals(headHash, head.getRootHash()))) { throw new VerificationFailedException(); } } }
From source file:gov.nih.nci.caarray.web.action.ArrayDesignAction.java
@SuppressWarnings("PMD.ExcessiveMethodLength") private void saveImportFile() { try {//ww w . j a v a 2 s .c o m // figure out if we are editing or creating. if (this.arrayDesign.getId() != null && (this.uploadFileName == null || this.uploadFileName.isEmpty())) { ServiceLocatorFactory.getArrayDesignService().saveArrayDesign(this.arrayDesign); } else { handleFiles(); } } catch (final RuntimeException re) { if (re.getCause() instanceof InvalidNumberOfArgsException) { final InvalidNumberOfArgsException inv = (InvalidNumberOfArgsException) re.getCause(); addFieldError(UPLOAD_FIELD_NAME, getText("arrayDesign.error." + inv.getMessage(), inv.getArguments().toArray(new String[inv.getArguments().size()]))); } else { addFieldError(UPLOAD_FIELD_NAME, getText("arrayDesign.error.importingFile")); } this.arrayDesign.getDesignFiles().clear(); } catch (final InvalidDataFileException e) { LOG.debug("Swallowed exception saving array design file", e); final FileValidationResult result = e.getFileValidationResult(); for (final ValidationMessage message : result.getMessages()) { addFieldError(UPLOAD_FIELD_NAME, message.getMessage()); } this.arrayDesign.getDesignFiles().clear(); } catch (final IllegalAccessException iae) { LOG.debug("Swallowed exception saving array design file", iae); this.arrayDesign = ServiceLocatorFactory.getArrayDesignService() .getArrayDesign(this.arrayDesign.getId()); addActionError(iae.getMessage()); } catch (final Exception e) { LOG.debug("Swallowed exception saving array design file", e); if (this.arrayDesign.getId() != null) { this.arrayDesign = ServiceLocatorFactory.getArrayDesignService() .getArrayDesign(this.arrayDesign.getId()); } addFieldError(UPLOAD_FIELD_NAME, getText("arrayDesign.error.importingFile")); } finally { // delete any files created as part of the unzipping process. // if the file uploaded was not a zip it will also be deleted if (this.uploads != null) { for (final File f : this.uploads) { f.delete(); } } } }
From source file:org.apache.flink.client.web.JobSubmissionServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter(ACTION_PARAM_NAME); if (checkParameterSet(resp, action, "action")) { return;//from w w w. j av a2 s. c om } // decide according to the action if (action.equals(ACTION_SUBMIT_VALUE)) { // --------------- submit a job ------------------- // get the parameters String options = req.getParameter(OPTIONS_PARAM_NAME); String jobName = req.getParameter(JOB_PARAM_NAME); String assemblerClass = req.getParameter(CLASS_PARAM_NAME); String arguments = req.getParameter(ARGUMENTS_PARAM_NAME); String showPlan = req.getParameter(SHOW_PLAN_PARAM_NAME); String suspendPlan = req.getParameter(SUSPEND_PARAM_NAME); // check that parameters are set // do NOT check 'options' or 'assemblerClass' -> it is OK if not set if (checkParameterSet(resp, jobName, JOB_PARAM_NAME) || checkParameterSet(resp, arguments, ARGUMENTS_PARAM_NAME) || checkParameterSet(resp, showPlan, SHOW_PLAN_PARAM_NAME) || checkParameterSet(resp, suspendPlan, SUSPEND_PARAM_NAME)) { return; } boolean show = Boolean.parseBoolean(showPlan); boolean suspend = Boolean.parseBoolean(suspendPlan); List<String> cliOptions; try { cliOptions = tokenizeArguments(options); } catch (IllegalArgumentException iaex) { showErrorPage(resp, "Flink options contain an unterminated quoted string."); return; } List<String> cliArguments; try { cliArguments = tokenizeArguments(arguments); } catch (IllegalArgumentException iaex) { showErrorPage(resp, "Program arguments contain an unterminated quoted string."); return; } String[] args = new String[1 + (assemblerClass == null ? 0 : 2) + cliOptions.size() + 1 + cliArguments.size()]; List<String> parameters = new ArrayList<String>(args.length); parameters.add(CliFrontend.ACTION_INFO); parameters.addAll(cliOptions); if (assemblerClass != null) { parameters.add("-" + CliFrontendParser.CLASS_OPTION.getOpt()); parameters.add(assemblerClass); } parameters.add(jobStoreDirectory + File.separator + jobName); parameters.addAll(cliArguments); FlinkPlan optPlan; try { this.cli.parseParameters(parameters.toArray(args)); optPlan = this.cli.getFlinkPlan(); if (optPlan == null) { // wrapping hack to get this exception handled correctly by following catch block throw new RuntimeException(new Exception("The optimized plan could not be produced.")); } } catch (RuntimeException e) { Throwable t = e.getCause(); if (t instanceof ProgramInvocationException) { // collect the stack trace StringWriter sw = new StringWriter(); PrintWriter w = new PrintWriter(sw); if (t.getCause() == null) { t.printStackTrace(w); } else { t.getCause().printStackTrace(w); } String message = sw.toString(); message = StringEscapeUtils.escapeHtml4(message); showErrorPage(resp, "An error occurred while invoking the program:<br/><br/>" + t.getMessage() + "<br/>" + "<br/><br/><pre>" + message + "</pre>"); return; } else if (t instanceof CompilerException) { // collect the stack trace StringWriter sw = new StringWriter(); PrintWriter w = new PrintWriter(sw); t.printStackTrace(w); String message = sw.toString(); message = StringEscapeUtils.escapeHtml4(message); showErrorPage(resp, "An error occurred in the compiler:<br/><br/>" + t.getMessage() + "<br/>" + (t.getCause() != null ? "Caused by: " + t.getCause().getMessage() : "") + "<br/><br/><pre>" + message + "</pre>"); return; } else { // collect the stack trace StringWriter sw = new StringWriter(); PrintWriter w = new PrintWriter(sw); t.printStackTrace(w); String message = sw.toString(); message = StringEscapeUtils.escapeHtml4(message); showErrorPage(resp, "An unexpected error occurred:<br/><br/>" + t.getMessage() + "<br/><br/><pre>" + message + "</pre>"); return; } } // redirect according to our options if (show) { // we have a request to show the plan // create a UID for the job Long uid; do { uid = Math.abs(this.rand.nextLong()); } while (this.submittedJobs.containsKey(uid)); // dump the job to a JSON file String planName = uid + ".json"; File jsonFile = new File(this.planDumpDirectory, planName); if (optPlan instanceof StreamingPlan) { ((StreamingPlan) optPlan).dumpStreamingPlanAsJSON(jsonFile); } else { PlanJSONDumpGenerator jsonGen = new PlanJSONDumpGenerator(); jsonGen.setEncodeForHTML(true); jsonGen.dumpOptimizerPlanAsJSON((OptimizedPlan) optPlan, jsonFile); } // submit the job only, if it should not be suspended if (!suspend) { parameters.set(0, CliFrontend.ACTION_RUN); try { this.cli.parseParameters(parameters.toArray(args)); } catch (RuntimeException e) { LOG.error("Error submitting job to the job-manager.", e.getCause()); showErrorPage(resp, e.getCause().getMessage()); return; } } else { this.submittedJobs.put(uid, this.cli.getJobGraph()); } // redirect to the plan display page resp.sendRedirect("showPlan?id=" + uid + "&suspended=" + (suspend ? "true" : "false")); } else { // don't show any plan. directly submit the job and redirect to the // runtime monitor parameters.set(0, CliFrontend.ACTION_RUN); try { this.cli.parseParameters(parameters.toArray(args)); } catch (RuntimeException e) { LOG.error("Error submitting job to the job-manager.", e.getCause()); // HACK: Is necessary because Message contains whole stack trace String errorMessage = e.getCause().getMessage().split("\n")[0]; showErrorPage(resp, errorMessage); return; } resp.sendRedirect(START_PAGE_URL); } } else if (action.equals(ACTION_RUN_SUBMITTED_VALUE)) { // --------------- run a job that has been submitted earlier, but was ------------------- // --------------- not executed because of a plan display ------------------- String id = req.getParameter("id"); if (checkParameterSet(resp, id, "id")) { return; } Long uid = null; try { uid = Long.parseLong(id); } catch (NumberFormatException nfex) { showErrorPage(resp, "An invalid id for the job was provided."); return; } // get the retained job JobGraph job = submittedJobs.remove(uid); if (job == null) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "No job with the given uid was retained for later submission."); return; } // submit the job try { Client client = new Client(GlobalConfiguration.getConfiguration(), getClass().getClassLoader()); client.run(job, false); } catch (Exception ex) { LOG.error("Error submitting job to the job-manager.", ex); resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); // HACK: Is necessary because Message contains whole stack trace String errorMessage = ex.getMessage().split("\n")[0]; resp.getWriter().print(errorMessage); // resp.sendError(HttpServletResponse.SC_BAD_REQUEST, ex.getMessage()); return; } // redirect to the start page resp.sendRedirect(START_PAGE_URL); } else if (action.equals(ACTION_BACK_VALUE)) { // remove the job from the map String id = req.getParameter("id"); if (checkParameterSet(resp, id, "id")) { return; } Long uid = null; try { uid = Long.parseLong(id); } catch (NumberFormatException nfex) { showErrorPage(resp, "An invalid id for the job was provided."); return; } // remove the retained job submittedJobs.remove(uid); // redirect to the start page resp.sendRedirect(START_PAGE_URL); } else { showErrorPage(resp, "Invalid action specified."); return; } }
From source file:org.wso2.carbon.registry.handlers.uri.utils.SchemaProcessor.java
public String importSchemaToRegistry(RequestContext requestContext, String resourcePath, String commonLocation, boolean processIncludes, String sourceURL) throws RegistryException { resourceName = resourcePath.substring(resourcePath.lastIndexOf(RegistryConstants.PATH_SEPARATOR) + 1); XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection(); xmlSchemaCollection.setBaseUri(sourceURL); baseURI = sourceURL;/*from w w w . j a v a 2 s.c om*/ InputSource inputSource = new InputSource(sourceURL); try { // Here we assue schema is correct. Schema validation is beyond our scope, so we don't // bother with a ValidationEventHandler. XmlSchema xmlSchema = xmlSchemaCollection.read(inputSource, null); evaluateSchemasRecursively(xmlSchema, null, false, true); } catch (RuntimeException re) { String msg = "Could not read the XML Schema Definition file. "; if (re.getCause() instanceof org.apache.ws.commons.schema.XmlSchemaException) { msg += re.getCause().getMessage(); log.error(msg, re); throw new RegistryException(msg); } throw new RegistryException(msg, re); } updateSchemaPaths(commonLocation); updateSchemaInternalsAndAssociations(); Resource metaResource = requestContext.getResource(); String path = saveSchemaToRegistry(requestContext, resourcePath, metaResource); // should depend on the central location / relative location flag persistAssociations(path); return path; }
From source file:org.nuclos.client.genericobject.GenericObjectDelegate.java
/** * updates the given leased object along with its dependants. * @param lowdcvo/*ww w. j a v a2s. co m*/ * @return the updated leased object (from the server) along with its dependants. * @throws NuclosFatalException if a fatal error occured * @throws CommonPermissionException if we have no permission to update the object * @throws CommonStaleVersionException if the object was changed in the meantime by another user * @throws NuclosBusinessRuleException * @precondition lowdcvo.getId() != null */ public GenericObjectWithDependantsVO update(GenericObjectWithDependantsVO lowdcvo, String customUsage) throws CommonBusinessException { if (lowdcvo.getId() == null) { throw new IllegalArgumentException("lowdcvo"); } try { LOG.debug("update start"); final GenericObjectWithDependantsVO result = this.getGenericObjectFacade().modify(lowdcvo.getModuleId(), lowdcvo, customUsage); LOG.debug("update done"); return result; } catch (RuntimeException ex) { final Throwable tCause = ex.getCause(); if (tCause instanceof BadGenericObjectException) { throw (BadGenericObjectException) tCause; } // RuntimeException has the BAD habit to include its cause' message in its own message. // the default message of NuclosUpdateException is not always correct ("duplicate key"). // cause of the exception will be added at Errors.java throw new NuclosUpdateException("GenericObjectDelegate.1", ex); } }