List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:se.inera.intyg.intygstjanst.web.integration.stub.SendMessageToCareResponderStub.java
@Override public SendMessageToCareResponseType sendMessageToCare(String logicalAddress, SendMessageToCareType parameters) { SendMessageToCareResponseType response = new SendMessageToCareResponseType(); ResultType resultType = new ResultType(); try {/* ww w.j a va2s . c om*/ storeMessage(parameters, logicalAddress); logger.info("STUB Received question concerning certificate with id: " + parameters.getIntygsId().getExtension()); resultType.setResultCode(ResultCodeType.OK); } catch (JAXBException e) { resultType.setResultCode(ResultCodeType.ERROR); resultType.setResultText("Error occurred when marshalling message to xml. " + e.getMessage()); response.setResult(resultType); return response; } catch (Throwable t) { t.printStackTrace(); throw t; } response.setResult(resultType); return response; }
From source file:org.kemri.wellcome.dhisreport.api.model.HttpDhis2Server.java
@Override public ImportSummary postReport(DataValueSet report) throws DHIS2ReportingException { log.debug("Posting datavalueset report"); ImportSummary summary = null;/* w w w . j a va 2 s. com*/ StringWriter xmlReport = new StringWriter(); try { JAXBContext jaxbDataValueSetContext = JAXBContext.newInstance(DataValueSet.class); Marshaller dataValueSetMarshaller = jaxbDataValueSetContext.createMarshaller(); // output pretty printed dataValueSetMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); dataValueSetMarshaller.marshal(report, xmlReport); } catch (JAXBException ex) { log.error(ex.getMessage()); throw new Dxf2Exception("Problem marshalling dataValueSet", ex); } String host = getUrl().getHost(); int port = getUrl().getPort(); HttpHost targetHost = new HttpHost(host, port, getUrl().getProtocol()); DefaultHttpClient httpclient = new DefaultHttpClient(); BasicHttpContext localcontext = new BasicHttpContext(); try { String postUrl = getUrl().toString() + DATAVALUESET_PATH; log.error("Post URL: " + postUrl); HttpPost httpPost = new HttpPost(postUrl); Credentials creds = new UsernamePasswordCredentials(username, password); Header bs = new BasicScheme().authenticate(creds, httpPost, localcontext); httpPost.addHeader("Authorization", bs.getValue()); httpPost.addHeader("Content-Type", "application/xml; charset=utf-8"); httpPost.addHeader("Accept", "application/xml"); httpPost.setEntity(new StringEntity(xmlReport.toString())); HttpResponse response = httpclient.execute(targetHost, httpPost, localcontext); HttpEntity entity = response.getEntity(); if (entity != null) { JAXBContext jaxbImportSummaryContext = JAXBContext.newInstance(ImportSummary.class); Unmarshaller importSummaryUnMarshaller = jaxbImportSummaryContext.createUnmarshaller(); summary = (ImportSummary) importSummaryUnMarshaller.unmarshal(entity.getContent()); } } catch (Exception ex) { log.error(ex.getMessage()); throw new Dhis2Exception(this, "Problem accessing Dhis2 server", ex); } finally { httpclient.getConnectionManager().shutdown(); } return summary; }
From source file:org.mitre.stixwebtools.services.TaxiiService.java
/** * Makes a poll request from a Taxii server to get a Taxii document. * //w ww .j av a 2 s . c o m * @param serverUrl * @param collection * @param subId * @param beginStr * @param endStr * @return */ public String getTaxiiDocument(URI serverUrl, String collection, String subId, String beginStr, String endStr) { HttpClient taxiiClient = getTaxiiClient("gatekeeper.mitre.org", 80); ObjectFactory factory = new ObjectFactory(); PollRequest pollRequest = factory.createPollRequest().withMessageId(MessageHelper.generateMessageId()) .withCollectionName(collection); if (!subId.isEmpty()) { pollRequest.setSubscriptionID(subId); } else { pollRequest.withPollParameters(factory.createPollParametersType()); } if (!beginStr.isEmpty()) { try { pollRequest.setExclusiveBeginTimestamp( DatatypeFactory.newInstance().newXMLGregorianCalendar(beginStr)); } catch (DatatypeConfigurationException eeeee) { } } if (!endStr.isEmpty()) { try { pollRequest .setExclusiveBeginTimestamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(endStr)); } catch (DatatypeConfigurationException eeeee) { } } String content; try { Object responseObj = taxiiClient.callTaxiiService(serverUrl, pollRequest); content = taxiiXml.marshalToString(responseObj, true); /*if (responseObj instanceof DiscoveryResponse) { DiscoveryResponse dResp = (DiscoveryResponse) responseObj; //processDiscoveryResponse(dResp); } else if (responseObj instanceof StatusMessage) { StatusMessage sm = (StatusMessage) responseObj; //processStatusMessage(sm); }*/ } catch (JAXBException e) { content = e.getMessage(); } catch (UnsupportedEncodingException eee) { content = eee.getMessage(); } catch (IOException eeee) { content = eeee.getMessage(); } return content; }
From source file:com.jaspersoft.jasperserver.rest.services.RESTJob.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { try {//www . jav a2s . c o m // Get the uri of the resource long jobId = getJobId(restUtils.extractRepositoryUri(req.getPathInfo())); // get the resources.... Job job = reportSchedulerService.getJob(jobId); StringWriter sw = new StringWriter(); // create JAXB context and instantiate marshaller restUtils.getMarshaller(Job.class).marshal(job, sw); restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, sw.toString()); } catch (JAXBException e) { throw new ServiceException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } catch (AxisFault axisFault) { throw new ServiceException(HttpServletResponse.SC_NOT_FOUND, axisFault.getMessage()); } }
From source file:be.fedict.eid.applet.service.signer.xps.XPSSignatureVerifier.java
public XPSSignatureVerifier() { try {//from ww w . ja v a2 s.c om JAXBContext relationshipsJAXBContext = JAXBContext.newInstance(ObjectFactory.class); this.relationshipsUnmarshaller = relationshipsJAXBContext.createUnmarshaller(); } catch (JAXBException e) { throw new RuntimeException("JAXB error: " + e.getMessage(), e); } }
From source file:org.geosdi.geoplatform.connector.server.request.GPPostConnectorRequest.java
@Override public InputStream getResponseAsStream() throws ServerInternalFault, IOException, IllegalParameterFault { try {/* w w w . ja v a2 s .co m*/ HttpResponse httpResponse = super.securityConnector.secure(this, this.getPostMethod()); HttpEntity responseEntity = httpResponse.getEntity(); if (responseEntity != null) { return responseEntity.getContent(); } else { throw new ServerInternalFault("Connector Server Error: Connection " + "problem"); } } catch (JAXBException ex) { logger.error("\n@@@@@@@@@@@@@@@@@@ JAXBException *** {} ***", ex.getMessage()); throw new ServerInternalFault("*** JAXBException ***" + ex); } catch (ClientProtocolException ex) { logger.error("\n@@@@@@@@@@@@@@@@@@ ClientProtocolException *** {} ***", ex.getMessage()); throw new ServerInternalFault("*** ClientProtocolException ***"); } }
From source file:it.isislab.sof.core.engine.hadoop.sshclient.connection.SofManager.java
public static boolean checkParamMakeSimulationFolder(String[] params) throws ParameterException { int SIMULATION_PSE_THRESHOLD = 7; //params[0]/*TOOLKIT TYPE MASON - NETLOGO -GENERIC*/, //params[1],/*SIM NAME*/ //params[2],/*INPUT.XML PATH*/ //params[3],/*OUTPUT.XML PATH */ //params[4],/*DESCRIPTION SIM*/ //params[5],/*SIMULATION EXEC PATH */ //params[6] //generic interpreter path /*params[0]MODEL TYPE MASON - NETLOGO -GENERIC, params[1],SIM NAME/*from w w w.j a va 2 s. c o m*/ params[2],domain_pathname params[3],bashCommandForRunnableFunctionSelect params[4],bashCommandForRunnableFunctionEvaluate params[5],output_description_filename params[6],executable_selection_function_filename params[7],executable_rating_function_filename params[8],description_simulation params[9],executable_simulation_filename params[10] //generic interpreter path*/ if (!(params[0].equalsIgnoreCase("netlogo") || params[0].equalsIgnoreCase("mason") || params[0].equalsIgnoreCase("generic"))) { throw new ParameterException("TOOLKIT NAME ERROR\n Use: [netlogo|mason|generic]\n"); } JAXBContext context; if (params.length > SIMULATION_PSE_THRESHOLD) { Domain dom = new Domain(); try { context = JAXBContext.newInstance(Domain.class); Unmarshaller unmarshal = context.createUnmarshaller(); dom = (Domain) unmarshal.unmarshal(new File(params[2])); } catch (JAXBException e) { throw new ParameterException("Invalid file DOMAIN.xml\n" + e.getMessage()); } } else { Inputs i = new Inputs(); try { context = JAXBContext.newInstance(Inputs.class); Unmarshaller unmarshal = context.createUnmarshaller(); i = (Inputs) unmarshal.unmarshal(new File(params[2])); } catch (JAXBException e) { throw new ParameterException("Invalid file INPUT.xml"); } } Output out = new Output(); try { context = JAXBContext.newInstance(Output.class); Unmarshaller unmarshal = context.createUnmarshaller(); if (params.length > SIMULATION_PSE_THRESHOLD) out = (Output) unmarshal.unmarshal(new File(params[5])); else out = (Output) unmarshal.unmarshal(new File(params[3])); } catch (JAXBException e) { throw new ParameterException("Invalid file OUTPUT.xml"); } if (params[0].equalsIgnoreCase("netlogo")) if (params.length > SIMULATION_PSE_THRESHOLD) { if (!params[9].endsWith(".nlogo")) throw new ParameterException("Invalid file extension netlogo"); } else { if (!params[5].endsWith(".nlogo")) throw new ParameterException("Invalid file extension netlogo"); } if (params[0].equalsIgnoreCase("mason")) if (params.length > SIMULATION_PSE_THRESHOLD) { if (!params[9].endsWith(".jar")) throw new ParameterException("Invalid file extension mason"); } else { if (!params[5].endsWith(".jar")) throw new ParameterException("Invalid file extension mason"); } return true; }
From source file:eu.eco2clouds.accounting.bonfire.BFClientAccountingImpl.java
@Override public Experiment getExperiment(String userId, long experimentId) { this.userId = userId; Boolean exception = false;// ww w .ja v a 2 s .c o m String experimentUrl = url + "/experiments/" + experimentId; String response = getMethod(experimentUrl, exception); logger.debug(response); Experiment experiment = new Experiment(); try { JAXBContext jaxbContext = JAXBContext.newInstance(Experiment.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); experiment = (Experiment) jaxbUnmarshaller.unmarshal(new StringReader(response)); } catch (JAXBException e) { logger.warn("Error trying to parse returned status of hosts: " + experimentUrl + " Exception: " + e.getMessage()); exception = true; } if (exception) return new Experiment(); return experiment; }
From source file:com.evolveum.midpoint.cli.ninja.action.Action.java
protected void handleError(String message, Exception ex) throws Exception { STD_ERR.info(message);/*from w w w.j a v a 2 s.c om*/ STD_ERR.info("Error occurred: {}", ex.getMessage()); if (ex instanceof FaultMessage) { FaultMessage faultMessage = (FaultMessage) ex; FaultType fault = faultMessage.getFaultInfo(); if (fault != null && fault.getOperationResult() != null) { OperationResultType result = fault.getOperationResult(); STD_ERR.info("Operation result: {}", result.getMessage()); if (getParams().isVerbose()) { try { STD_ERR.debug(ToolsUtils.serializeObject(result)); } catch (JAXBException e) { STD_ERR.debug("Couldn't serialize operation result, reason: {}", e.getMessage()); } } } } if (getParams().isVerbose()) { STD_ERR.debug("Error details", ex); } throw ex; }
From source file:nc.noumea.mairie.appock.viewmodel.EditStockReferentServiceViewModel.java
@Command public void exportStockXlsx() { boolean hasError = false; String message = null;//from www. j a v a 2 s . c o m try (ByteArrayOutputStream out = new ByteArrayOutputStream();) { StockSpreadsheetExporter.exportToXls(authHelper.getCurrentUser().getService(), getListeArticleStock(), catalogueService, out); AMedia amedia = new AMedia("inventaire.xlsx", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", out.toByteArray()); Filedownload.save(amedia); } catch (JAXBException e) { hasError = true; message = e.getMessage(); log.error("An error accored during stock xlsx export : " + e.getMessage(), e); } catch (Docx4JException e) { hasError = true; message = e.getMessage(); log.error("An error accored during stock xlsx export : " + e.getMessage(), e); } catch (IOException e) { hasError = true; message = e.getMessage(); log.error("An error accored during stock xlsx export : " + e.getMessage(), e); } if (hasError) { Messagebox.show("Une erreur s'est produite durant l'export Excel.", "Export chou", Messagebox.OK, Messagebox.ERROR); return; } }