List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.GridRowLoader.java
/** * The method import schema rows from schema file into schema grid. * //ww w . j av a 2 s.c o m */ public List<GridRow> importGridRowsFromXML(ListenerHelper helper, Table table) { List<GridRow> schemaGridRowListToImport = null; ELTGridDetails gridDetails = (ELTGridDetails) helper.get(HelperType.SCHEMA_GRID); List<GridRow> grids = gridDetails.getGrids(); grids.clear(); try (InputStream xml = new FileInputStream(schemaFile); InputStream xsd = new FileInputStream(SCHEMA_CONFIG_XSD_PATH);) { if (StringUtils.isNotBlank(schemaFile.getPath())) { if (!schemaFile.getName().contains(".")) { logger.error(Messages.IMPORT_XML_IMPROPER_EXTENSION); throw new Exception(Messages.IMPORT_XML_IMPROPER_EXTENSION); } if (!(schemaFile.getPath().endsWith(".schema")) && !(schemaFile.getPath().endsWith(".xml"))) { logger.error(Messages.IMPORT_XML_INCORRECT_FILE); throw new Exception(Messages.IMPORT_XML_INCORRECT_FILE); } if (validateXML(xml, xsd)) { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setExpandEntityReferences(false); builderFactory.setNamespaceAware(true); builderFactory.setFeature(Constants.DISALLOW_DOCTYPE_DECLARATION, true); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(schemaFile); JAXBContext jaxbContext = JAXBContext.newInstance(Schema.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Schema schema = (Schema) jaxbUnmarshaller.unmarshal(document); fields = schema.getFields(); List<Field> fieldsList = fields.getField(); GridRow gridRow = null; schemaGridRowListToImport = new ArrayList<GridRow>(); if (Messages.GENERIC_GRID_ROW.equals(gridRowType)) { for (Field field : fieldsList) { addRowToList(gridDetails, grids, getBasicSchemaGridRow(field), schemaGridRowListToImport); } } else if (Messages.FIXEDWIDTH_GRID_ROW.equals(gridRowType)) { for (Field field : fieldsList) { addRowToList(gridDetails, grids, getFixedWidthGridRow(field), schemaGridRowListToImport); } } else if (Messages.GENERATE_RECORD_GRID_ROW.equals(gridRowType)) { for (Field field : fieldsList) { addRowToList(gridDetails, grids, getGenerateRecordGridRow(field), schemaGridRowListToImport); } } else if (Messages.XPATH_GRID_ROW.equals(gridRowType)) { for (Field field : fieldsList) { Text loopXPathData = null; if (table.getData() != null && Text.class.isAssignableFrom(table.getData().getClass())) { loopXPathData = (Text) table.getData(); } XPathGridRow xPathGridRow = new XPathGridRow(); populateCommonFields(xPathGridRow, field); xPathGridRow.setXPath(field.getAbsoluteOrRelativeXpath()); if (loopXPathData != null && StringUtils.isNotBlank(loopXPathData.getText())) { xPathGridRow.setAbsolutexPath( loopXPathData.getText() + Path.SEPARATOR + xPathGridRow.getXPath()); } else { xPathGridRow.setAbsolutexPath(xPathGridRow.getXPath()); } addRowToList(gridDetails, grids, xPathGridRow, schemaGridRowListToImport); } } else if (Messages.MIXEDSCHEME_GRID_ROW.equals(gridRowType)) { for (Field field : fieldsList) { addRowToList(gridDetails, grids, getMixedSchemeGridRow(field), schemaGridRowListToImport); } } } } else { logger.error(Messages.EXPORT_XML_EMPTY_FILENAME); throw new Exception(Messages.EXPORT_XML_EMPTY_FILENAME); } } catch (JAXBException e1) { grids.clear(); showMessageBox(Messages.IMPORT_XML_FORMAT_ERROR + " -\n" + e1.getMessage(), "Error", SWT.ERROR); logger.error(Messages.IMPORT_XML_FORMAT_ERROR); return null; } catch (DuplicateFieldException e1) { grids.clear(); showMessageBox(e1.getMessage(), "Error", SWT.ERROR); logger.error(e1.getMessage()); return null; } catch (Exception e) { grids.clear(); showMessageBox(Messages.IMPORT_XML_ERROR + " -\n" + e.getMessage(), "Error", SWT.ERROR); logger.error(Messages.IMPORT_XML_ERROR); return null; } return schemaGridRowListToImport; }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.GridRowLoader.java
/** * The method exports schema rows from schema grid into schema file. * /* w ww .j a v a2 s . c o m*/ */ public void exportXMLfromGridRows(List<GridRow> schemaGridRowList) { Schema schema = new Schema(); fields = new Fields(); try { if (StringUtils.isNotBlank(schemaFile.getPath())) { if (!schemaFile.getName().contains(".")) { logger.error(Messages.EXPORT_XML_IMPROPER_EXTENSION); throw new Exception(Messages.EXPORT_XML_IMPROPER_EXTENSION); } if (!(schemaFile.getPath().endsWith(".schema")) && !(schemaFile.getPath().endsWith(".xml"))) { logger.error(Messages.EXPORT_XML_INCORRECT_FILE); throw new Exception(Messages.EXPORT_XML_INCORRECT_FILE); } exportFile(schemaGridRowList, schema); showMessageBox(Messages.EXPORTED_SCHEMA, "Information", SWT.ICON_INFORMATION); } else { logger.error(Messages.EXPORT_XML_EMPTY_FILENAME); throw new Exception(Messages.EXPORT_XML_EMPTY_FILENAME); } } catch (JAXBException e) { showMessageBox( Messages.EXPORT_XML_ERROR + " -\n" + ((e.getCause() != null) ? e.getLinkedException().getMessage() : e.getMessage()), "Error", SWT.ERROR); logger.error(Messages.EXPORT_XML_ERROR); } catch (Exception e) { showMessageBox(Messages.EXPORT_XML_ERROR + " -\n" + e.getMessage(), "Error", SWT.ERROR); logger.error(Messages.EXPORT_XML_ERROR); } }
From source file:com.snaplogic.snaps.firstdata.Create.java
private String getGMFXMLRequestData(com.snaplogic.snaps.firstdata.gmf.proxy.GMFMessageVariants gmfmv) { StringWriter stringWriter = new StringWriter(); String returnValue = ""; try {//from w w w . j av a 2s.c o m JAXBContext context = null; Marshaller marshaller = null; context = JAXBContext.newInstance(GMFMessageVariants.class); marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, XML_ENCODING); marshaller.marshal(gmfmv, stringWriter); returnValue = stringWriter.toString(); } catch (JAXBException jaxe) { log.error(jaxe.getMessage(), jaxe); throw new SnapDataException(jaxe, jaxe.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); throw new SnapDataException(e, e.getMessage()); } return returnValue; }
From source file:edu.indiana.d2i.sloan.ui.JobSubmitAction.java
/** * upload job to registry and submit it to Sigiri web services *///from w w w . j av a 2 s . co m public String execute() { if (!isValidForm()) return INPUT; if (logger.isDebugEnabled()) { if (worksetCheckbox != null) { StringBuilder worksetList = new StringBuilder(); for (String idx : worksetCheckbox) worksetList.append(idx + " "); logger.debug("Selected worksets=" + worksetList.toString()); } else { logger.debug("No worksets being selected"); } } try { uploadJob(); } catch (JAXBException e) { logger.error(e.getMessage(), e); errMsg = "Invalid job description file"; logger.error(errMsg); addActionError(e.getMessage()); return INPUT; } catch (RemoteException e) { logger.error(e.getMessage(), e); addActionError("Sigiri service exception:" + e.getMessage()); return ERROR; } catch (NullSigiriJobIdException e) { logger.error(e.getMessage(), e); addActionError("Sigiri service exception:" + e.getMessage()); return ERROR; } catch (XMLStreamException e) { logger.error(e.getMessage(), e); addActionError("Sigiri service exception:" + e.getMessage()); return ERROR; } catch (RegistryExtException e) { logger.error(e.getMessage(), e); addActionError("Registry service exception" + e.getMessage()); return ERROR; } catch (HttpException e) { logger.error(e.getMessage(), e); addActionError("Registry service exception" + e.getMessage()); return ERROR; } catch (IOException e) { logger.error(e.getMessage(), e); addActionError(e.getMessage()); return ERROR; } catch (OAuthSystemException e) { logger.error(e.getMessage(), e); addActionError(e.getMessage()); return ERROR; } catch (OAuthProblemException e) { logger.error(e.getMessage(), e); addActionError(e.getMessage()); return ERROR; } finally { String errString = "Exception occurred when cleaning up dangling job:"; try { removeDanglingJob(); } catch (HttpException e) { logger.error(errString + e.getMessage(), e); } catch (IOException e) { logger.error(errString + e.getMessage(), e); } catch (RegistryExtException e) { logger.error(errString + e.getMessage(), e); } catch (OAuthSystemException e) { logger.error(errString + e.getMessage(), e); } catch (OAuthProblemException e) { logger.error(errString + e.getMessage(), e); } } return SUCCESS; }
From source file:gov.nih.nci.cacis.sa.transcend.client.TranscendSemanticAdapter.java
/** * AcceptSource operation accepts data from Clinical Source system and sends it to Mirth Connect for processing * // ww w . j a v a 2 s. c o m * @param parameter caCISRequest * @return CaCISResponse * @throws AcceptSourceFault Web Service Fault */ @WebResult(name = "caCISResponse", targetNamespace = "http://cacis.nci.nih.gov", partName = "parameter") @WebMethod public CaCISResponse acceptSource( @WebParam(partName = "parameter", name = "caCISRequest", targetNamespace = "http://cacis.nci.nih.gov") CaCISRequest parameter) throws AcceptSourceFault { LOG.debug("Executing operation acceptSource"); final gov.nih.nci.cacis.sa.transcend.CaCISResponse response = new CaCISResponse(); final String reqstr = getCaCISRequestxml(parameter); if (StringUtils.isEmpty(reqstr)) { throw new AcceptSourceFault("Error marshalling CaCISRequest!"); } String mcResponse = webServiceMessageReceiver.processData(reqstr); if (LOG.isDebugEnabled()) { LOG.debug("TranscendSemanticAdapter..MC RESPONSE:" + mcResponse); } if (mcResponse != null && (mcResponse.indexOf("Error") > -1 || mcResponse.indexOf("Exception") > -1 || mcResponse.indexOf("ERROR") > -1 || mcResponse.indexOf("error") > -1)) { mcResponse = StringUtils.remove(mcResponse, "SUCCESS:"); mcResponse = StringUtils.remove(mcResponse, "FAILURE:"); AcceptSourceFault fault; try { fault = new AcceptSourceFault("Error processing Data from Source System", getCaCISFaultFromXml(mcResponse)); throw fault; } catch (JAXBException ex) { final CaCISFault cf = new CaCISFault(); final CaCISError ce = new CaCISError(); final IntegrationError ie = IntegrationError._1000; ce.setErrorCode(String.valueOf(ie.getErrorCode())); ce.setErrorMessage(ie.getMessage((Object) null)); ce.setErrorType(ErrorType.TRANSMISSION); ce.setDetail(stackTraceAsString(ex)); cf.getCaCISError().add(ce); fault = new AcceptSourceFault("Error accepting Data from Source System!" + ex.getMessage(), cf); throw fault; } } response.setStatus(ResponseStatusType.SUCCESS); return response; }
From source file:com.xerox.amazonws.sqs.MessageQueue.java
private void addGrant(Map<String, String> params) throws SQSException { GetMethod method = new GetMethod(); try {//from w ww.j a v a2 s . c om //AddGrantResponse response = makeRequest(method, "AddGrant", params, AddGrantResponse.class); } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.sqs.MessageQueue.java
private void removeGrant(Map<String, String> params) throws SQSException { GetMethod method = new GetMethod(); try {/*w ww .j a v a 2 s .c o m*/ //RemoveGrantResponse response = makeRequest(method, "RemoveGrant", params, RemoveGrantResponse.class); } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.sqs.MessageQueue.java
/** * Deletes the message identified by msgid on the queue this object represents. * * @param msgId the id of the message to be deleted *//*from w w w. ja v a 2 s .co m*/ public void deleteMessage(String msgId) throws SQSException { Map<String, String> params = new HashMap<String, String>(); params.put("MessageId", msgId); GetMethod method = new GetMethod(); try { //DeleteMessageResponse response = makeRequest(method, "DeleteMessage", params, DeleteMessageResponse.class); } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.sqs.MessageQueue.java
/** * Sends a message to a specified queue. The message must be between 1 and 256K bytes long. * * @param msg the message to be sent//from ww w . j a va 2 s . co m */ public String sendMessage(String msg) throws SQSException { Map<String, String> params = new HashMap<String, String>(); String encodedMsg = enableEncoding ? new String(Base64.encodeBase64(msg.getBytes())) : msg; PostMethod method = new PostMethod(); try { method.setRequestEntity(new StringRequestEntity(encodedMsg, "text/plain", null)); SendMessageResponse response = makeRequest(method, "SendMessage", params, SendMessageResponse.class); return response.getMessageId(); } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.xerox.amazonws.sqs.MessageQueue.java
/** * Deletes the message queue represented by this object. * * @param force when true, non-empty queues will be deleted *//*from w ww . ja va2s. c om*/ public void deleteQueue(boolean force) throws SQSException { Map<String, String> params = new HashMap<String, String>(); if (force) { params.put("ForceDeletion", "true"); } GetMethod method = new GetMethod(); try { //DeleteQueueResponse response = makeRequest(method, "DeleteQueue", params, DeleteQueueResponse.class); } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }