List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:org.openbel.framework.tools.Backtrack.java
private Document convert(final File f) throws ConversionError { try {/*from w w w . j a va2 s .c om*/ Document document = converter.toCommon(f); return document; } catch (JAXBException e) { final String name = f.getAbsolutePath(); final String msg = e.getMessage(); final Throwable cause = e; throw new ConversionError(name, msg, cause); } catch (IOException e) { final String name = f.getAbsolutePath(); final String msg = e.getMessage(); final Throwable cause = e; throw new ConversionError(name, msg, cause); } }
From source file:org.opencastproject.videoeditor.impl.VideoEditorServiceImpl.java
/** * {@inheritDoc}/* w ww .j a v a 2 s . c o m*/ * * @see * org.opencastproject.videoeditor.api.VideoEditorService#processSmil(org.opencastproject.smil.entity.Smil) */ @Override public List<Job> processSmil(Smil smil) throws ProcessFailedException { if (smil == null) { throw new ProcessFailedException("Smil document is null!"); } List<Job> jobs = new LinkedList<Job>(); try { for (SmilMediaParamGroup paramGroup : smil.getHead().getParamGroups()) { for (SmilMediaParam param : paramGroup.getParams()) { if (SmilMediaParam.PARAM_NAME_TRACK_ID.equals(param.getName())) { jobs.add(serviceRegistry.createJob(getJobType(), Operation.PROCESS_SMIL.toString(), Arrays.asList(smil.toXML(), paramGroup.getId()))); } } } return jobs; } catch (JAXBException ex) { throw new ProcessFailedException("Failed to serialize smil " + smil.getId()); } catch (ServiceRegistryException ex) { throw new ProcessFailedException("Failed to create job: " + ex.getMessage()); } catch (Exception ex) { throw new ProcessFailedException(ex.getMessage()); } }
From source file:org.opencds.knowledgeRepository.SimpleKnowledgeRepository.java
public static synchronized Unmarshaller getRequiredUnmarshallerInstanceForUnmarshallerClassCache(String ssid) throws DSSRuntimeExceptionFault //Object for unmarshallerInstance should be cast when it is used to IPayloadUnmarshaller { Unmarshaller unmarshallerInstance = myUnmarshallerClassNameToUnmarshallerInstanceCache.get(ssid); if (unmarshallerInstance == null) { log.debug(ssid + ": creating unmarshaller instance in cache"); try {//from www. j a v a2s . c o m unmarshallerInstance = getRequiredJAXBContextForUnmarshallerClassCache(ssid).createUnmarshaller(); } catch (JAXBException e) { throw new DSSRuntimeExceptionFault( "requested Unmarshaller for SSID: " + ssid + " created JAXBException: " + e.getMessage()); } myUnmarshallerClassNameToUnmarshallerInstanceCache.putIfAbsent(ssid, unmarshallerInstance); return unmarshallerInstance; } else { log.debug(ssid + ": using unmarshaller instance from cache"); return unmarshallerInstance; } }
From source file:org.opencds.knowledgeRepository.SimpleKnowledgeRepository.java
public static synchronized Marshaller getRequiredMarshallerInstanceForMarshallerClassCache(String className, JAXBContext jaxbContext) throws DSSRuntimeExceptionFault { Marshaller marshallerInstance = myPayloadCreatorClassNameToMarshallerInstanceCache.get(className); if (marshallerInstance == null) { log.debug(className + ": creating marshaller instance"); try {//from w w w.j av a2s.c om marshallerInstance = jaxbContext.createMarshaller(); marshallerInstance.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshallerInstance.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); } catch (JAXBException e) { throw new DSSRuntimeExceptionFault("requested Marshaller for className: " + className + " created JAXBException: " + e.getMessage()); } myPayloadCreatorClassNameToMarshallerInstanceCache.putIfAbsent(className, marshallerInstance); return marshallerInstance; } else { log.debug(className + ": using marshaller instance from cache"); return marshallerInstance; } }
From source file:org.openhab.action.openwebif.internal.impl.OpenWebIfCommunicator.java
/** * Executes the http request and parses the returned stream. *//* w ww. jav a2s . c o m*/ @SuppressWarnings("unchecked") private <T> T executeRequest(OpenWebIfConfig config, String url, Class<T> clazz) throws IOException { HttpURLConnection con = null; try { logger.trace("Request [{}]: {}", config.getName(), url); con = (HttpURLConnection) new URL(url).openConnection(); con.setConnectTimeout(CONNECTION_TIMEOUT); con.setReadTimeout(10000); if (config.hasLogin()) { String userpass = config.getUser() + ":" + config.getPassword(); String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userpass.getBytes()); con.setRequestProperty("Authorization", basicAuth); } if (con instanceof HttpsURLConnection) { HttpsURLConnection sCon = (HttpsURLConnection) con; TrustManager[] trustManager = new TrustManager[] { new SimpleTrustManager() }; SSLContext context = SSLContext.getInstance("TLS"); context.init(new KeyManager[0], trustManager, new SecureRandom()); sCon.setSSLSocketFactory(context.getSocketFactory()); sCon.setHostnameVerifier(new AllowAllHostnameVerifier()); } StringWriter sw = new StringWriter(); IOUtils.copy(con.getInputStream(), sw); con.disconnect(); if (con.getResponseCode() == HttpURLConnection.HTTP_OK) { String response = sw.toString(); logger.trace("Response: [{}]: {}", config.getName(), response); Unmarshaller um = JAXBContext.newInstance(clazz).createUnmarshaller(); return (T) um.unmarshal(new StringReader(response)); } else { throw new IOException(con.getResponseMessage()); } } catch (JAXBException ex) { throw new IOException(ex.getMessage(), ex); } catch (GeneralSecurityException ex) { throw new IOException(ex.getMessage(), ex); } finally { if (con != null) { con.disconnect(); } } }
From source file:org.openhab.binding.homematic.internal.communicator.client.CcuClient.java
/** * Load predefined scripts from an XML file. *//* www . j a v a 2 s . c o m*/ private Map<String, String> loadTclRegaScripts() throws HomematicClientException { try { Unmarshaller um = JAXBContext.newInstance(TclScripts.class).createUnmarshaller(); InputStream stream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("homematic/tclrega-scripts.xml"); TclScripts scripts = (TclScripts) um.unmarshal(stream); Map<String, String> result = new HashMap<String, String>(); for (TclScript script : scripts.getScripts()) { result.put(script.getName(), script.getData()); } return result; } catch (JAXBException ex) { throw new HomematicClientException(ex.getMessage(), ex); } }
From source file:org.openhab.binding.homematic.internal.communicator.client.TclRegaScriptClient.java
/** * Load predefined scripts from an XML file. */// ww w . j a v a 2s . com private Map<String, String> loadTclRegaScripts() throws CcuClientException { try { Unmarshaller um = JAXBContext.newInstance(TclScripts.class).createUnmarshaller(); InputStream stream = Thread.currentThread().getContextClassLoader() .getResourceAsStream("homematic/tclrega-scripts.xml"); TclScripts scripts = (TclScripts) um.unmarshal(stream); Map<String, String> result = new HashMap<String, String>(); for (TclScript script : scripts.getScripts()) { result.put(script.getName(), script.getData()); } return result; } catch (JAXBException ex) { throw new CcuClientException(ex.getMessage(), ex); } }
From source file:org.openhealthtools.openxds.registry.adapter.omar31.XdsRegistryQueryServiceImpl.java
public OMElement sqlQuery(RegistrySQLQueryContext context) throws RegistryQueryException { OMElement ret = null;/* www. ja va2s. c om*/ String sql = context.getSql(); boolean returnLeafClass = context.isLeafClass(); if (sql == null || sql.equals("")) { throw new RegistryQueryException("Invalid SQL query"); } if (log.isDebugEnabled()) { log.debug("Invoking SQL Query: " + sql); } SQLQueryProcessor qp = SQLQueryProcessor.getInstance(); org.oasis.ebxml.registry.bindings.query.ResponseOption responseOption = null; try { responseOption = BindingUtility.getInstance().queryFac.createResponseOption(); responseOption.setReturnComposedObjects(true); if (returnLeafClass) { responseOption.setReturnType(org.oasis.ebxml.registry.bindings.query.ReturnType.LEAF_CLASS); } else { responseOption.setReturnType(org.oasis.ebxml.registry.bindings.query.ReturnType.OBJECT_REF); } } catch (javax.xml.bind.JAXBException e) { throw new RegistryQueryException("Failed to create ResponseOption - " + e.getMessage(), e); } String contextId = "org:openhealthexchange:openxds:registry:adapter:omar31:XdsRegistryQueryManager:sqlQuery:context"; ServerRequestContext src = null; RegistryObjectListType rolt = null; IterativeQueryParams paramHolder = new IterativeQueryParams(0, -1); try { src = new ServerRequestContext(contextId, null); rolt = qp.executeQuery(src, null, sql, responseOption, paramHolder); } catch (RegistryException e) { try { src.rollback(); } catch (RegistryException re) { throw new RegistryQueryException("Failed to rollback - " + re.getMessage(), re); } throw new RegistryQueryException("Failed to create ResponseOption - " + e.getMessage(), e); } try { org.oasis.ebxml.registry.bindings.query.AdhocQueryResponse ahqr = BindingUtility.getInstance().queryFac .createAdhocQueryResponse(); ahqr.setRegistryObjectList(rolt); ahqr.setStatus(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success); ahqr.setStartIndex(BigInteger.valueOf(paramHolder.startIndex)); ahqr.setTotalResultCount(BigInteger.valueOf(paramHolder.totalResultCount)); String response = BindingUtility.getInstance().marshalObject(ahqr); if (log.isDebugEnabled()) { log.debug("SQL Response:\n" + response); } ret = OMUtil.xmlStringToOM(response); } catch (javax.xml.bind.JAXBException e) { throw new RegistryQueryException("Failed to create AdhocQueryResponse - " + e.getMessage(), e); } catch (XMLStreamException e) { throw new RegistryQueryException( "Could not create XMLStream from AdhocQueryResponse - " + e.getMessage(), e); } try { src.commit(); } catch (RegistryException re) { throw new RegistryQueryException("Failed to commmit - " + re.getMessage(), re); } //Finally return the result return ret; }
From source file:org.openhim.mediator.normalization.ParseProvideAndRegisterRequestActor.java
private void processMsg(SimpleMediatorRequest<String> msg) { ActorRef requestHandler = msg.getRequestHandler(); CoreResponse.Orchestration orch = null; boolean sendParseOrchestration = (config == null || config.getProperty("pnr.sendParseOrchestration") == null || "true".equalsIgnoreCase(config.getProperty("pnr.sendOrchestration"))); try {/* www . j av a2s . co m*/ if (sendParseOrchestration) { orch = new CoreResponse.Orchestration(); orch.setName("Parse Provider and Register Document Set.b contents"); orch.setRequest(new CoreResponse.Request()); } ProvideAndRegisterDocumentSetRequestType result = parseRequest(msg.getRequestObject()); msg.getRespondTo().tell(new SimpleMediatorResponse<>(msg, result), getSelf()); if (sendParseOrchestration) { orch.setResponse(new CoreResponse.Response()); requestHandler.tell(new AddOrchestrationToCoreResponse(orch), getSelf()); } } catch (JAXBException ex) { FinishRequest fr = new FinishRequest( "Failed to parse XDS.b Provide and Register Document Set request: " + ex.getMessage(), "text/plain", HttpStatus.SC_BAD_REQUEST); requestHandler.tell(fr, getSelf()); } }
From source file:org.opennaas.extensions.network.test.DummyParserTest.java
public OutputStream saveNetworkDescriptor(NetworkTopology networkDescriptor, OutputStream stream) { try {/* ww w . jav a 2s .c om*/ JAXBContext context = JAXBContext.newInstance(NetworkTopology.class); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(networkDescriptor, stream); } catch (JAXBException e) { log.error(e.getMessage(), e.getCause()); } return stream; }