List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:gov.nih.nci.cabig.caaers.service.ProxyWebServiceFacade.java
public ProxyWebServiceFacade() { try {/*from w w w.j a v a 2 s. co m*/ jaxbContext = JAXBContext.newInstance("gov.nih.nci.cabig.caaers.integration.schema.study"); unmarshaller = jaxbContext.createUnmarshaller(); xsltTransformer = new XsltTransformer(); } catch (JAXBException jb) { throw new CaaersConfigurationException("Unable to create proxy webservice : " + jb.getMessage(), jb); } }
From source file:eu.eco2clouds.scheduler.bonfire.BFClientSchedulerImpl.java
private Compute changeStateCompute(String userId, Compute compute, String state) { this.userId = userId; Boolean exception = false;/*ww w . j ava 2 s .c o m*/ String computeURL = url + compute.getHref(); Compute computeMessage = new Compute(); computeMessage.setHref(compute.getHref()); computeMessage.setState(state); computeMessage.setLinks(compute.getLinks()); String payload = ""; try { JAXBContext jaxbContext = JAXBContext.newInstance(Compute.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); ByteArrayOutputStream out = new ByteArrayOutputStream(); marshaller.marshal(computeMessage, out); payload = out.toString(); } catch (JAXBException e) { logger.warn("Error trying to parse returned status of hosts: " + computeURL + " Exception: " + e.getMessage()); exception = true; } String response = putMethod(computeURL, payload, exception); logger.debug(response); try { JAXBContext jaxbContext = JAXBContext.newInstance(Compute.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); compute = (Compute) jaxbUnmarshaller.unmarshal(new StringReader(response)); } catch (JAXBException e) { logger.warn("Error trying to parse returned status of hosts: " + computeURL + " Exception: " + e.getMessage()); exception = true; } if (exception) return new Compute(); return compute; }
From source file:com.aurel.track.configExchange.importer.EntityImporter.java
public List<ImportResult> importFile(InputStream is, ImportContext importContext) throws EntityImporterException { boolean overwriteExisting = importContext.isOverrideExisting(); boolean overrideOnlyNotModifiedByUser = importContext.isOverrideOnlyNotModifiedByUser(); boolean clearChildren = importContext.isClearChildren(); String type = importContext.getEntityType(); Map<String, String> extraAttributes = importContext.getAttributeMap(); LOGGER.debug("Import file overwriteExisting=" + overwriteExisting + " type=" + type); List<ImportResult> result = new ArrayList<ImportResult>(); Unmarshaller unmarshaller = null; try {//from www . j ava 2s . c o m unmarshaller = EntityExporter.getUnmarshaller(); } catch (JAXBException e) { throw new EntityImporterException("JAXBException:" + e.getMessage(), e); } catch (SAXException e) { throw new EntityImporterException("SAXException:" + e.getMessage(), e); } JAXBElement<TrackplusRoot> root = null; try { root = (JAXBElement<TrackplusRoot>) unmarshaller.unmarshal(is); } catch (JAXBException e) { throw new EntityImporterException("JAXBException:" + e.getMessage(), e); } TrackplusRoot trackplusExchangeRoot = root.getValue(); //collect all dependences as map List<DependencyData> globalDependencyList = trackplusExchangeRoot.getEntityDependency(); for (DependencyData dependency : globalDependencyList) { String dependencyType = dependency.getType(); Map<Integer, Entity> entityMap = globalDependencies.get(dependencyType); if (entityMap == null) { entityMap = new HashMap<Integer, Entity>(); globalDependencies.put(dependencyType, entityMap); } List<Entity> dependencyEntityList = dependency.getTrackEntity(); for (Entity dependencyEntity : dependencyEntityList) { entityMap.put(Integer.parseInt(dependencyEntity.getEntityId()), dependencyEntity); } } // save dependency first LOGGER.debug("Saving dependences...."); for (DependencyData dependency : globalDependencyList) { List<Entity> dependencyEntityList = dependency.getTrackEntity(); for (Entity dependencyEntity : dependencyEntityList) { EntityImportContext entityImportContext = new EntityImportContext(); entityImportContext.setEntity(dependencyEntity); entityImportContext.setAttributeMap(toAttributeMap(dependencyEntity.getEntityAttribute())); entityImportContext.setOverrideExisting(false); entityImportContext.setClearChildren(false); saveEntity(entityImportContext); } } LOGGER.debug("Dependences saved!"); // save entity list List<Entity> entityExchangeList = trackplusExchangeRoot.getEntityExchange(); LOGGER.debug("entityExchangeList size:" + entityExchangeList.size()); Map<String, String> attributes; for (Entity entity : entityExchangeList) { LOGGER.debug("entity " + entity.getType() + " id:" + entity.getEntityId()); if (type != null && !type.equals(entity.getType())) { LOGGER.debug("invalid entity type"); continue; } attributes = toAttributeMap(entity.getEntityAttribute()); //override attributes if (extraAttributes != null) { Iterator<String> it = extraAttributes.keySet().iterator(); while (it.hasNext()) { String key = it.next(); String value = extraAttributes.get(key); if (value == null) { attributes.remove(key); } else { attributes.put(key, value); } } } EntityImportContext entityImportContext = new EntityImportContext(); entityImportContext.setEntity(entity); entityImportContext.setAttributeMap(attributes); entityImportContext.setOverrideExisting(overwriteExisting); entityImportContext.setClearChildren(clearChildren); entityImportContext.setOverrideOnlyNotModifiedByUser(overrideOnlyNotModifiedByUser); ImportResult importResult = saveEntity(entityImportContext); result.add(importResult); } return result; }
From source file:com.lmco.ddf.endpoints.subscriptions.SubscriptionService.java
/** * Constructor for Subscription REST service. * /*from w w w .j a v a 2 s.co m*/ * @param EventProcessor the MTS EventProcessor to use to * create/update/delete/query subscriptions */ public SubscriptionService(BundleContext context, EventProcessor EventProcessor) { this.context = context; this.eventProcessor = EventProcessor; try { JAXBContext jc = JAXBContext.newInstance(Subscription.class); this.unmarshaller = jc.createUnmarshaller(); } catch (JAXBException e) { logger.warn(e.getMessage(), e); } }
From source file:edu.harvard.lib.lcloud.ItemDAO.java
/** * Returns SearchResultsSlim for a given SolrDocumentList. A "slimmer" results object without the * "items" wrapper element is created for better transform to json. * @param doc solr document list to build results * @return the SearchResultsSlim object for this solr result * @see SearchResultsSlim//from w w w.ja v a 2 s.c o m */ private SearchResultsSlim buildSlimResults(SolrDocumentList docs) { SearchResultsSlim results = new SearchResultsSlim(); Pagination pagination = new Pagination(); pagination.setNumFound(docs.getNumFound()); pagination.setStart(docs.getStart()); pagination.setRows(limit); //List<ModsType> modsTypes = new ArrayList<ModsType>(); List<Item> items = new ArrayList<Item>(); for (final SolrDocument doc : docs) { Item item = new Item(); ModsType modsType = null; try { modsType = (new ItemDAO()).getModsType(doc); } catch (JAXBException je) { log.error(je.getMessage()); je.printStackTrace(); } item.setModsType(modsType); items.add(item); } results.setItems(items); results.setPagination(pagination); if (facet != null) results.setFacet(facet); return results; }
From source file:edu.harvard.lib.lcloud.ItemDAO.java
/** * Returns SearchResults for a given SolrDocumentList. A full results object with an "items" wrapper * element around the mods items is used to logically separate pagination, items and facets in the XML * @param doc solr document list to build results * @return the SearchResults object for this solr result * @see SearchResults//from ww w. j av a 2 s . c o m */ private SearchResults buildFullResults(SolrDocumentList docs) { SearchResults results = new SearchResults(); Pagination pagination = new Pagination(); pagination.setNumFound(docs.getNumFound()); pagination.setStart(docs.getStart()); pagination.setRows(limit); //List<ModsType> modsTypes = new ArrayList<ModsType>(); ItemGroup itemGroup = new ItemGroup(); List<Item> items = new ArrayList<Item>(); for (final SolrDocument doc : docs) { Item item = new Item(); ModsType modsType = null; try { modsType = (new ItemDAO()).getModsType(doc); } catch (JAXBException je) { log.error(je.getMessage()); je.printStackTrace(); } //modsTypes.add(modsType); //items.add(item); item.setModsType(modsType); items.add(item); } //items.setModsType(modsType); itemGroup.setItems(items); results.setItemGroup(itemGroup); results.setPagination(pagination); if (facet != null) results.setFacet(facet); return results; }
From source file:com.xerox.amazonws.sqs2.MessageQueue.java
/** * Deletes the message queue represented by this object. Will delete non-empty queue. *//*from ww w. ja va2 s .c om*/ public void deleteQueue() throws SQSException { Map<String, String> params = new HashMap<String, String>(); 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(); } }
From source file:com.xerox.amazonws.sqs2.MessageQueue.java
/** * Deletes the message identified by receiptHandle on the queue this object represents. * * @param receiptHandle the handle of the message to be deleted *//*from w w w.ja v a 2 s .c om*/ public void deleteMessage(String receiptHandle) throws SQSException { Map<String, String> params = new HashMap<String, String>(); params.put("ReceiptHandle", receiptHandle); 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.sqs2.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 w w w .ja 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; params.put("MessageBody", encodedMsg); PostMethod method = new PostMethod(); try { SendMessageResponse response = makeRequest(method, "SendMessage", params, SendMessageResponse.class); return response.getSendMessageResult().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:gov.nih.nci.integration.caaers.CaAERSParticipantServiceWSClient.java
/** * Constructor//www . j a v a 2 s.co m * * @param serviceUrl - URL * @param userName - user name * @param clientPasswordCallback - clientPasswordCallback * @throws IntegrationException - IntegrationException */ public CaAERSParticipantServiceWSClient(String serviceUrl, String userName, ClientPasswordCallback clientPasswordCallback) throws IntegrationException { super(); this.userName = userName; this.clientPasswordCallback = clientPasswordCallback; try { getUnmarshaller(); initClient(serviceUrl); } catch (JAXBException e) { LOG.error("CaAERSParticipantServiceWSClient..JAXBException while unmarshlling", e); throw new IntegrationException(IntegrationError._1054, e.getMessage());// NOPMD } }