List of usage examples for javax.xml.stream XMLStreamException getCause
public synchronized Throwable getCause()
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
public void open() { try {// w w w . jav a 2s . com XMLOutputFactory factory = XMLOutputFactory.newInstance(); writer = factory.createXMLStreamWriter(stream); if (!compressedXml) { writer = new IndentingXMLStreamWriter(writer); } writeStartDocument(); } catch (XMLStreamException e) { throw new TurnusRuntimeException("Error opening the trace stream writer", e.getCause()); } }
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
public void writeAttribute(String name, Object value) { try {/* w w w. j ava2 s .com*/ writer.writeStartElement(ATTRIBUTE); writer.writeAttribute(ATTRIBUTE_NAME, name); writeObject(value); writer.writeEndElement(); } catch (XMLStreamException e) { throw new TurnusRuntimeException("Trace Writer Error: " + e.getLocalizedMessage(), e.getCause()); } }
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
private void writeStartDocument() { try {//from w w w . jav a 2 s . c o m String date = new SimpleDateFormat("yyyy.MM.dd, HH:mm:ss").format(new Date()); writer.writeStartDocument(); writer.writeComment("Trace exported the " + date); writer.writeStartElement(TRACE); } catch (XMLStreamException e) { throw new TurnusRuntimeException("Trace Writer Error: " + e.getLocalizedMessage(), e.getCause()); } }
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
public void write(Step step) { try {/* w w w.j av a 2s . c o m*/ boolean noAttributes = hasEmptyAttributes(step); if (noAttributes) { writer.writeEmptyElement(STEP); } else { writer.writeStartElement(STEP); } writer.writeAttribute(STEP_FIRING, Long.toString(step.getID())); writer.writeAttribute(STEP_ACTOR, step.getActor()); writer.writeAttribute(STEP_ACTION, step.getAction()); writer.writeAttribute(STEP_ACTOR_CLASS, step.getActorClass()); if (!noAttributes) { writeAttributes(step); writer.writeEndElement(); } } catch (XMLStreamException e) { throw new TurnusRuntimeException("Trace Writer Error: " + e.getLocalizedMessage(), e.getCause()); } }
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
@SuppressWarnings("rawtypes") private void writeObject(Object v) { try {/* w ww. j a va2s .com*/ if (v instanceof Boolean) { writer.writeEmptyElement(TYPE_BOOLEAN); writer.writeAttribute(VALUE, Boolean.toString((Boolean) v)); } else if (v instanceof Byte || v instanceof Short || v instanceof Integer) { writer.writeEmptyElement(TYPE_INTEGER); writer.writeAttribute(VALUE, Integer.toString((Integer) v)); } else if (v instanceof Long) { writer.writeEmptyElement(TYPE_INTEGER); writer.writeAttribute(VALUE, Long.toString((Long) v)); } else if (v instanceof Float) { writer.writeEmptyElement(TYPE_REAL); writer.writeAttribute(VALUE, Float.toString((Float) v)); } else if (v instanceof Double) { writer.writeEmptyElement(TYPE_REAL); writer.writeAttribute(VALUE, Double.toString((Double) v)); } else if (v instanceof String) { writer.writeEmptyElement(TYPE_STRING); writer.writeAttribute(VALUE, (String) v); } else if (v instanceof List) { writer.writeStartElement(TYPE_LIST); for (Object o : (List) v) { writeObject(o); } writer.writeEndElement(); } else if (v instanceof Set) { writer.writeStartElement(TYPE_SET); for (Object o : (Set) v) { writeObject(o); } writer.writeEndElement(); } else if (v instanceof Map) { writer.writeStartElement(TYPE_MAP); for (Object k : ((Map) v).keySet()) { writer.writeStartElement(ENTRY); writeObject(k); writeObject(((Map) v).get(k)); writer.writeEndElement(); } writer.writeEndElement(); } } catch (XMLStreamException e) { throw new TurnusRuntimeException("Trace Writer Error: " + e.getLocalizedMessage(), e.getCause()); } }
From source file:co.turnus.trace.io.XmlTraceStreamWriter.java
public void write(Dependency dep) { try {/*from w w w. ja v a 2 s . co m*/ boolean noAttributes = hasEmptyAttributes(dep); if (noAttributes) { writer.writeEmptyElement(DEPENDENCY); } else { writer.writeStartElement(DEPENDENCY); } writer.writeAttribute(DEPENDENCY_SOURCE, Long.toString(dep.getSource().getID())); writer.writeAttribute(DEPENDENCY_TARGET, Long.toString(dep.getTarget().getID())); Kind kind = dep.getKind(); writer.writeAttribute(DEPENDENCY_KIND, dep.getKind().literal()); switch (kind) { case FSM: { break; } case TOKENS: { writer.writeAttribute(SOURCE_PORT, dep.getSourcePort()); writer.writeAttribute(TARGET_PORT, dep.getTargetPort()); writer.writeAttribute(COUNT, Integer.toString(dep.getCount())); break; } case STATEVAR: { writer.writeAttribute(VARIABLE, dep.getVariable()); writer.writeAttribute(DIRECTION, dep.getDirection().literal()); break; } case PORT: { writer.writeAttribute(PORT, dep.getPort()); writer.writeAttribute(DIRECTION, dep.getDirection().literal()); break; } case GUARD: { writer.writeAttribute(GUARD, dep.getGuard()); writer.writeAttribute(DIRECTION, dep.getDirection().literal()); break; } default: throw new TurnusRuntimeException("Unsupported Dependence kind " + dep); } if (!noAttributes) { writeAttributes(dep); writer.writeEndElement(); } } catch (XMLStreamException e) { throw new TurnusRuntimeException("Trace Writer Error: " + e.getLocalizedMessage(), e.getCause()); } }
From source file:com.snaplogic.snaps.checkfree.CheckfreeExecute.java
@Override @SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument") protected void process(final Document document, final String inputViewName) { String envelope = null;/*from ww w .j a v a2 s . co m*/ String strippedEnvelope = null; Object documentData = document != null ? document.get() : null; List<Header> headerList = soapUtils.buildHeaderList(document, documentData, httpHeaders); Header[] headers = headerList.toArray(new Header[0]); // remove all previous created ones, its a static registry List<Interceptor<? extends Message>> outInterceptors = bus.getOutInterceptors(); soapUtils.resetInterceptors(outInterceptors, SoapMessageSenderInterceptor.class); SoapMessageSenderInterceptor soapMessageSenderInterceptor = new SoapMessageSenderInterceptor(headers, trustAllCerts, null, null); outInterceptors.add(soapMessageSenderInterceptor); try { envelope = editorProperty.eval(document); if (!useDefaultValueChecked) { strippedEnvelope = xmlUtils.stripElementsAndAttributesExceptSOAPHeader(envelope, documentBuilderFactory); envelope = strippedEnvelope; } LOGGER.info(DISPATCHING_SOAP_REQUEST, envelope); SOAPMessage soapResponse = invocationService.call(clientBuilder, envelope); if (soapResponse == null) { return; } Object data = invocationService.serialize(soapResponse); if (data != null) { outputViews.write(documentUtility.newDocument(data), document); documentCounter.inc(); } } catch (XMLStreamException e) { throw new ExecutionException(e, XML_SERIALIZATION_FAILED).withResolutionAsDefect(); } catch (Exception e) { Throwable rootCause = Throwables.getRootCause(e); String reason = rootCause.getMessage(); Map<String, Object> errorMap = Maps.newHashMap(); errorMap.put(KEY_ERROR, reason); errorMap.put(STACKTRACE, Throwables.getStackTraceAsString(e.getCause() != null ? e.getCause() : e)); SnapDataException dataException = new SnapDataException(documentUtility.newDocument(errorMap), e, EXCEPTION_OCCURRED).withReason(reason).withResolution(SOAP_EXCEPTION_RESOLUTION); // serialize headers Map<String, Object> soapHeaders = Maps.newHashMap(); Dispatch<SOAPMessage> dispatchClient = clientBuilder.getDispatchClient(); Map<?, Object> requestContext = dispatchClient.getRequestContext(); if (requestContext != null) { soapUtils.serializeHeader(requestContext, soapHeaders); } Message message = soapMessageSenderInterceptor.getMessage(); if (message != null) { // protocol headers are the ones passed into the http/s request. soapUtils.serializeHeader((Map<?, Object>) message.get(Message.PROTOCOL_HEADERS), soapHeaders); } for (Header header : headerList) { String name = header.getName(); if (name != null) { soapHeaders.put(name, header.getValue()); } } errorMap.put(REQUEST_HEADERS, soapHeaders); // serialize the envelope if (envelope != null) { errorMap.put(KEY_ENVELOPE, parseXML2JSON(envelope, xmlUtils)); } if (strippedEnvelope != null) { errorMap.put(KEY_STRIPPED_ENVELOPE, parseXML2JSON(strippedEnvelope, xmlUtils)); } errorViews.write(dataException, document); } }
From source file:org.fudgemsg.wire.xml.FudgeXMLStreamWriter.java
/** * Wraps an exception into a runtime exception. * //from w w w . j ava 2 s . co m * @param operation the operation being attempted when the exception was caught * @param ex the exception caught * @return A fudgeRuntimeException */ protected static FudgeRuntimeException wrapException(final String operation, final XMLStreamException ex) { if (ex.getCause() instanceof IOException) { return new FudgeRuntimeIOException((IOException) ex.getCause()); } else { return new FudgeRuntimeException("Couldn't " + operation + " XML stream", ex); } }
From source file:org.fudgemsg.xml.FudgeXMLStreamWriter.java
/** * @param operation the operation being attempted when the exception was caught * @param e the exception caught/*w w w . j ava 2s . c o m*/ */ protected static FudgeRuntimeException wrapException(final String operation, XMLStreamException e) { if (e.getCause() instanceof IOException) { return new FudgeRuntimeIOException((IOException) e.getCause()); } else { return new FudgeRuntimeException("Couldn't " + operation + " XML stream", e); } }
From source file:org.osaf.cosmo.eim.eimml.EimmlStreamReader.java
/** * Reads the document header and root element, positioning the * cursor just before the first recordset. *///from ww w. j av a2 s . c o m public EimmlStreamReader(Reader in) throws IOException, EimmlStreamException { try { xmlReader = XML_INPUT_FACTORY.createXMLStreamReader(in); if (!xmlReader.hasNext()) throw new EimmlStreamException("Input stream has no data"); readEncoding(); readCollection(); } catch (XMLStreamException e) { throw new EimmlStreamException("Unable to read EIM records", e); } catch (RuntimeException e) { Throwable t = e.getCause(); if (t != null && t instanceof XMLStreamException) throw new EimmlStreamException("Error reading next recordset", t); throw e; } }