public Throwable getLinkedException() { return getCause(); }
public Throwable getLinkedException() { return getCause(); }
public Throwable getLinkedException() { return getCause(); }
public Throwable getLinkedException() { return getCause(); }
public <T> T convertXMLToObject(Class<T> clazz, String xml) { T instance = null; try { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); instance = (clazz.cast(unmarshaller.unmarshal(new StringReader(xml)))); } catch (JAXBException ex) { LOGGER.error(ex.getCause().getMessage(), ex); } return instance; }
private JAXBContext getContext() { try { return JAXBContextFactory.initContext(Report.class); } catch (JAXBException ex) { throw new RuntimeException("Unable to initialize JAXBContext.", ex.getCause()); } } }
public static CustomReportType unmarshalCR(String reportXML) throws RaptorException { //CustomReport cr = null; try { JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj"); Unmarshaller u = jc.createUnmarshaller(); javax.xml.bind.JAXBElement<CustomReportType> doc = (javax.xml.bind.JAXBElement<CustomReportType>) u.unmarshal(new java.io.StringReader( reportXML)); return doc.getValue(); } catch (JAXBException ex) { ex.printStackTrace(); throw new RaptorException (ex.getMessage(), ex.getCause()); } } // unmarshal
@SuppressWarnings("unchecked") protected <T> T parseStructure(final Deque<XMLSecEvent> eventDeque, final int index, final XMLSecurityProperties securityProperties) throws XMLSecurityException { try { Unmarshaller unmarshaller = XMLSecurityConstants.getJaxbUnmarshaller(securityProperties.isDisableSchemaValidation()); return (T) unmarshaller.unmarshal(new XMLSecurityEventReader(eventDeque, index)); } catch (JAXBException e) { if (e.getCause() != null && e.getCause() instanceof Exception) { throw new XMLSecurityException((Exception)e.getCause()); } throw new XMLSecurityException(e); } }
protected void handleJAXBException(JAXBException e, boolean read) { StringBuilder sb = handleExceptionStart(e); Throwable linked = e.getLinkedException(); if (linked != null && linked.getMessage() != null) { if (read && linked instanceof XMLStreamException && linked.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } sb.append(linked.getMessage()).append(". "); } Throwable t = linked != null ? linked : e.getCause() != null ? e.getCause() : e; String message = new org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", BUNDLE, sb.toString()).toString(); handleExceptionEnd(t, message, read); }
@Override public WorkflowBundle readBundle(InputStream inputStream, String mediaType) throws ReaderException, IOException { try { WorkflowBundle bundle = getParser().parseScufl(inputStream); scufl2Tools.setParents(bundle); return bundle; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse SCUFL", e); } }
/** Translate a JAXB unmarshal exception into something legible. */ private static <T> InvalidDataException translateJaxbUnmarshalError(Class<T> type, JAXBException e) { boolean added = false; InvalidDataException invalid = getUnmarshalError(type, e); // This was developed through trial-and-error. I don't know how well it will hold up in the future. if (e.getCause() != null && e.getLinkedException() != null) { try { throw e.getLinkedException(); } catch (org.xml.sax.SAXParseException sax) { String message = "Line " + sax.getLineNumber() + ", column " + sax.getColumnNumber() + ": " + e.getCause().getMessage(); invalid.getDetails().addMessage(ERROR_KEY, message); added = true; } catch (Throwable other) { } } if (!added && e.getCause() != null && e.getCause().getMessage() != null) { invalid.getDetails().addMessage(ERROR_KEY, e.getCause().getMessage()); added = true; } if (!added && e.getMessage() != null) { invalid.getDetails().addMessage(ERROR_KEY, e.getMessage()); added = true; } return invalid; }
@Override public WorkflowBundle readBundle(File bundleFile, String mediaType) throws ReaderException, IOException { try { WorkflowBundle bundle = getParser().parseScufl(bundleFile); scufl2Tools.setParents(bundle); return bundle; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse SCUFL " + bundleFile, e); } }
public String marshal() throws RaptorException { StringWriter sw = new StringWriter(); ObjectFactory objFactory = new ObjectFactory(); try { JAXBContext jc = JAXBContext.newInstance("org.onap.portalsdk.analytics.xmlobj"); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); //JAXBElement jaxbElement = new JAXBElement(new QName("customReport"), Object.class, ""); //m.marshal( System.out ); //m.marshal(jaxbElement, new StreamResult(sw)); m.marshal((getTableWithoutColumns() == null) ? objFactory.createCustomReport(cr) : objFactory.createCustomReport(cloneCustomReportClearTables()), new StreamResult(sw)); } catch (JAXBException ex) { throw new RaptorException (ex.getMessage(), ex.getCause()); } return sw.toString(); } // marshal
@Override public WorkflowBundle readBundle(File bundleFile, String mediaType) throws ReaderException, IOException { try { WorkflowBundle bundle = getParser().parseT2Flow(bundleFile); scufl2Tools.setParents(bundle); preserveOriginal(bundle, new FileInputStream(bundleFile)); return bundle; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse t2flow " + bundleFile, e); } }
protected void handleJAXBException(JAXBException e, boolean read) { StringBuilder sb = handleExceptionStart(e); Throwable linked = e.getLinkedException(); if (linked != null && linked.getMessage() != null) { Throwable cause = linked; while (read && cause != null) { if (cause instanceof XMLStreamException && cause.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } if (cause instanceof DepthExceededStaxException) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } cause = cause.getCause(); } String msg = linked.getMessage(); if (sb.lastIndexOf(msg) == -1) { sb.append(msg).append(". "); } } Throwable t = linked != null ? linked : e.getCause() != null ? e.getCause() : e; String message = new org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", BUNDLE, sb.toString()).toString(); handleExceptionEnd(t, message, read); }
if (e.getCause() != null) { InternalLogger.INSTANCE.error("Failed to parse configuration file: '%s'", ExceptionUtils.getStackTrace(e));
public SemaphoreType addSemaphore(ObjectFactory objFactory, SemaphoreType semaphoreType) throws RaptorException { SemaphoreType sem = null; try { if (getSemaphoreList() == null) setSemaphoreList(objFactory.createSemaphoreList()); String semaphoreName = null; boolean nameExists = true; for (int i = 1; nameExists; i++) { semaphoreName = semaphoreType.getSemaphoreName() + ((i > 1) ? (" v" + i) : ""); nameExists = false; for (Iterator iter2 = getSemaphoreList().getSemaphore().iterator(); iter2 .hasNext();) if (semaphoreName.equals(((SemaphoreType) iter2.next()).getSemaphoreName())) { nameExists = true; break; } } // for sem = cloneSemaphoreType(objFactory, semaphoreType); getSemaphoreList().getSemaphore().add(sem); sem.setSemaphoreId(generateNewSemaphoreId()); sem.setSemaphoreName(semaphoreName); } catch (JAXBException ex) { throw new RaptorException(ex.getMessage(), ex.getCause()); } return sem; } // addSemaphore
Throwable cause = e.getCause(); if (cause instanceof Exception) { cause = Exceptions.unwrap((Exception) cause);
Throwable cause = e.getCause(); if (cause instanceof Exception) { cause = Exceptions.unwrap((Exception) cause);