List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:org.flowable.cmmn.converter.export.PlanItemExport.java
public static void writePlanItem(PlanItem planItem, XMLStreamWriter xtw) throws Exception { // start plan item element xtw.writeStartElement(ELEMENT_PLAN_ITEM); xtw.writeAttribute(ATTRIBUTE_ID, planItem.getId()); if (StringUtils.isNotEmpty(planItem.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, planItem.getName()); }//from ww w .j av a2s.c o m if (StringUtils.isNotEmpty(planItem.getDefinitionRef())) { xtw.writeAttribute(ATTRIBUTE_DEFINITION_REF, planItem.getDefinitionRef()); } if (StringUtils.isNotEmpty(planItem.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(planItem.getDocumentation()); xtw.writeEndElement(); } if (planItem.getItemControl() != null) { xtw.writeStartElement(ELEMENT_ITEM_CONTROL); RepetitionRule repetitionRule = planItem.getItemControl().getRepetitionRule(); if (repetitionRule != null) { xtw.writeStartElement(ELEMENT_REPETITION_RULE); if (StringUtils.isNotEmpty(repetitionRule.getRepetitionCounterVariableName())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_REPETITION_COUNTER_VARIABLE_NAME, repetitionRule.getRepetitionCounterVariableName()); } if (StringUtils.isNotEmpty(repetitionRule.getCondition())) { xtw.writeStartElement(ELEMENT_CONDITION); xtw.writeCData(repetitionRule.getCondition()); xtw.writeEndElement(); } xtw.writeEndElement(); } xtw.writeEndElement(); } CriteriaExport.writeCriteriaElements(planItem, xtw); // end plan item element xtw.writeEndElement(); }
From source file:org.flowable.cmmn.converter.export.ProcessTaskExport.java
public static void writeProcessTask(ProcessTask processTask, XMLStreamWriter xtw) throws Exception { // start process task element xtw.writeStartElement(ELEMENT_PROCESS_TASK); writeCommonTaskAttributes(xtw, processTask); if (StringUtils.isNotEmpty(processTask.getProcessRef()) || StringUtils.isNotEmpty(processTask.getProcessRefExpression())) { xtw.writeStartElement(ELEMENT_PROCESS_REF_EXPRESSION); xtw.writeCData(StringUtils.isNotEmpty(processTask.getProcessRef()) ? processTask.getProcessRef() : processTask.getProcessRefExpression()); xtw.writeEndElement(); }//from ww w . j a v a 2 s . c o m // end process task element xtw.writeEndElement(); }
From source file:org.flowable.cmmn.converter.export.SentryExport.java
public static void writeSentry(Sentry sentry, XMLStreamWriter xtw) throws Exception { // start sentry element xtw.writeStartElement(ELEMENT_SENTRY); xtw.writeAttribute(ATTRIBUTE_ID, sentry.getId()); if (StringUtils.isNotEmpty(sentry.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, sentry.getName()); }/*w w w . ja va 2 s . co m*/ for (SentryOnPart sentryOnPart : sentry.getOnParts()) { // start sentry on part element xtw.writeStartElement(ELEMENT_PLAN_ITEM_ON_PART); xtw.writeAttribute(ATTRIBUTE_ID, sentryOnPart.getId()); xtw.writeAttribute(ATTRIBUTE_SOURCE_REF, sentryOnPart.getSourceRef()); // start standard event element xtw.writeStartElement(ELEMENT_STANDARD_EVENT); xtw.writeCharacters(sentryOnPart.getStandardEvent()); xtw.writeEndElement(); // end sentry on part element xtw.writeEndElement(); } // If part if (sentry.getSentryIfPart() != null) { xtw.writeStartElement(ELEMENT_IF_PART); xtw.writeStartElement(ELEMENT_CONDITION); xtw.writeCData(sentry.getSentryIfPart().getCondition()); xtw.writeEndElement(); xtw.writeEndElement(); } // end plan item element xtw.writeEndElement(); }
From source file:org.flowable.cmmn.converter.export.ServiceTaskExport.java
public static void writeTask(ServiceTask task, XMLStreamWriter xtw) throws Exception { // start task element xtw.writeStartElement(ELEMENT_TASK); writeCommonTaskAttributes(xtw, task); if (StringUtils.isNotEmpty(task.getType())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE, task.getType());/*from ww w. ja v a 2 s. c om*/ if (ServiceTask.JAVA_TASK.equals(task.getType())) { if (StringUtils.isNotEmpty(task.getImplementation())) { if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(task.getImplementationType())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_CLASS, task.getImplementation()); } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION .equals(task.getImplementationType())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_EXPRESSION, task.getImplementation()); } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION .equals(task.getImplementationType())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_DELEGATE_EXPRESSION, task.getImplementation()); } } if (StringUtils.isNotEmpty(task.getResultVariableName())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_RESULT_VARIABLE_NAME, task.getResultVariableName()); } } } if (HttpServiceTask.HTTP_TASK.equals(task.getType())) { if (StringUtils.isNotEmpty(task.getImplementation())) { xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_CLASS, task.getImplementation()); } } writeExtensions(task, xtw); // end task element xtw.writeEndElement(); }
From source file:org.flowable.cmmn.converter.export.ServiceTaskExport.java
public static void writeExtensions(TaskWithFieldExtensions task, XMLStreamWriter xtw) throws XMLStreamException { if (task.getFieldExtensions().size() > 0) { xtw.writeStartElement(ELEMENT_EXTENSIONS); for (FieldExtension fieldExtension : task.getFieldExtensions()) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FIELD, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_NAME, fieldExtension.getFieldName()); if (StringUtils.isNotEmpty(fieldExtension.getStringValue())) { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FIELD_STRING, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeCData(fieldExtension.getStringValue()); } else { xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ATTRIBUTE_FIELD_EXPRESSION, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeCData(fieldExtension.getExpression()); }/*from w w w .j a v a 2 s. co m*/ xtw.writeEndElement(); xtw.writeEndElement(); } xtw.writeEndElement(); } }
From source file:org.flowable.cmmn.converter.export.StageExport.java
public static void writeStage(Stage stage, XMLStreamWriter xtw) throws Exception { // start plan model or stage element if (stage.isPlanModel()) { xtw.writeStartElement(ELEMENT_PLAN_MODEL); } else {//from w ww. ja v a 2 s . c om xtw.writeStartElement(ELEMENT_STAGE); } xtw.writeAttribute(ATTRIBUTE_ID, stage.getId()); if (StringUtils.isNotEmpty(stage.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, stage.getName()); } if (StringUtils.isNotEmpty(stage.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(stage.getDocumentation()); xtw.writeEndElement(); } for (PlanItem planItem : stage.getPlanItems()) { PlanItemExport.writePlanItem(planItem, xtw); } for (Sentry sentry : stage.getSentries()) { SentryExport.writeSentry(sentry, xtw); } for (PlanItemDefinition planItemDefinition : stage.getPlanItemDefinitions()) { PlanItemDefinitionExport.writePlanItemDefinition(planItemDefinition, xtw); } if (stage.isPlanModel() && stage.getExitCriteria() != null && !stage.getExitCriteria().isEmpty()) { for (Criterion exitCriterion : stage.getExitCriteria()) { xtw.writeStartElement(ELEMENT_EXIT_CRITERION); xtw.writeAttribute(ATTRIBUTE_ID, exitCriterion.getId()); if (StringUtils.isNotEmpty(exitCriterion.getName())) { xtw.writeAttribute(ATTRIBUTE_NAME, exitCriterion.getName()); } if (StringUtils.isNotEmpty(exitCriterion.getSentryRef())) { xtw.writeAttribute(ATTRIBUTE_SENTRY_REF, exitCriterion.getSentryRef()); } // end entry criterion element xtw.writeEndElement(); } } // end plan model or stage element xtw.writeEndElement(); }
From source file:org.flowable.cmmn.converter.export.TimerEventListenerExport.java
public static void writeTimerEventListener(TimerEventListener timerEventListener, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_TIMER_EVENT_LISTENER); writeCommonPlanItemDefinitionAttributes(timerEventListener, xtw); if (StringUtils.isNotEmpty(timerEventListener.getTimerExpression())) { xtw.writeStartElement(ELEMENT_TIMER_EXPRESSION); xtw.writeCData(timerEventListener.getTimerExpression()); xtw.writeEndElement(); }//from w w w. j ava 2 s . c o m if (StringUtils.isNotEmpty(timerEventListener.getTimerStartTriggerSourceRef())) { xtw.writeStartElement(ELEMENT_PLAN_ITEM_START_TRIGGER); xtw.writeAttribute(ATTRIBUTE_PLAN_ITEM_START_TRIGGER_SRC_REF, timerEventListener.getTimerStartTriggerSourceRef()); xtw.writeStartElement(ELEMENT_STANDARD_EVENT); xtw.writeCData(timerEventListener.getTimerStartTriggerStandardEvent()); xtw.writeEndElement(); xtw.writeEndElement(); } xtw.writeEndElement(); }
From source file:org.flowable.cmmn.converter.util.CmmnXmlUtil.java
protected static void writeExtensionElement(ExtensionElement extensionElement, Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception { if (StringUtils.isNotEmpty(extensionElement.getName())) { Map<String, String> localNamespaceMap = new HashMap<>(); if (StringUtils.isNotEmpty(extensionElement.getNamespace())) { if (StringUtils.isNotEmpty(extensionElement.getNamespacePrefix())) { xtw.writeStartElement(extensionElement.getNamespacePrefix(), extensionElement.getName(), extensionElement.getNamespace()); if (!namespaceMap.containsKey(extensionElement.getNamespacePrefix()) || !namespaceMap .get(extensionElement.getNamespacePrefix()).equals(extensionElement.getNamespace())) { xtw.writeNamespace(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); namespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); localNamespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace()); }// ww w. j a v a 2 s. c om } else { xtw.writeStartElement(extensionElement.getNamespace(), extensionElement.getName()); } } else { xtw.writeStartElement(extensionElement.getName()); } for (List<ExtensionAttribute> attributes : extensionElement.getAttributes().values()) { for (ExtensionAttribute attribute : attributes) { if (StringUtils.isNotEmpty(attribute.getName()) && attribute.getValue() != null) { if (StringUtils.isNotEmpty(attribute.getNamespace())) { if (StringUtils.isNotEmpty(attribute.getNamespacePrefix())) { if (!namespaceMap.containsKey(attribute.getNamespacePrefix()) || !namespaceMap .get(attribute.getNamespacePrefix()).equals(attribute.getNamespace())) { xtw.writeNamespace(attribute.getNamespacePrefix(), attribute.getNamespace()); namespaceMap.put(attribute.getNamespacePrefix(), attribute.getNamespace()); } xtw.writeAttribute(attribute.getNamespacePrefix(), attribute.getNamespace(), attribute.getName(), attribute.getValue()); } else { xtw.writeAttribute(attribute.getNamespace(), attribute.getName(), attribute.getValue()); } } else { xtw.writeAttribute(attribute.getName(), attribute.getValue()); } } } } if (extensionElement.getElementText() != null) { xtw.writeCData(extensionElement.getElementText()); } else { for (List<ExtensionElement> childElements : extensionElement.getChildElements().values()) { for (ExtensionElement childElement : childElements) { writeExtensionElement(childElement, namespaceMap, xtw); } } } for (String prefix : localNamespaceMap.keySet()) { namespaceMap.remove(prefix); } xtw.writeEndElement(); } }
From source file:org.gatein.management.rest.FailureResponse.java
private void writeXml(OutputStream out, boolean pretty) throws IOException { XMLStreamWriter writer; try {//from w w w . j ava 2 s . c o m writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out); } catch (XMLStreamException e) { throw new IOException("Could not create XML streaming writer.", e); } try { writer.writeStartDocument("UTF-8", "1.0"); // root element <failureResult> nl(writer, pretty); writer.writeStartElement("failureResult"); nl(writer, pretty); indent(writer, 1, pretty); // <failure> writer.writeStartElement("failure"); writer.writeCharacters(outcome.getFailureDescription()); writer.writeEndElement(); nl(writer, pretty); indent(writer, 1, pretty); // <operationName> writer.writeStartElement("operationName"); writer.writeCharacters(operationName); writer.writeEndElement(); nl(writer, pretty); // </failureResult> writer.writeEndElement(); // End document writer.writeCharacters("\n"); writer.writeEndDocument(); writer.flush(); } catch (XMLStreamException e) { throw new IOException("Exception writing failure response to XML. Failure response message was '" + outcome.getFailureDescription() + "'", e); } // finally // { // try // { // writer.close(); // } // catch (XMLStreamException e) // { // // ignore // } // } }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private void handleBlobList(HttpServletRequest request, HttpServletResponse response, BlobStore blobStore, String containerName) throws IOException, S3Exception { String blobStoreType = getBlobStoreType(blobStore); ListContainerOptions options = new ListContainerOptions(); String encodingType = request.getParameter("encoding-type"); String delimiter = request.getParameter("delimiter"); if (delimiter != null) { options.delimiter(delimiter);//from www. j av a 2 s. co m } else { options.recursive(); } String prefix = request.getParameter("prefix"); if (prefix != null && !prefix.isEmpty()) { options.prefix(prefix); } String marker = request.getParameter("marker"); if (marker != null) { if (Quirks.OPAQUE_MARKERS.contains(blobStoreType)) { String realMarker = lastKeyToMarker.getIfPresent(Maps.immutableEntry(containerName, marker)); if (realMarker != null) { marker = realMarker; } } options.afterMarker(marker); } int maxKeys = 1000; String maxKeysString = request.getParameter("max-keys"); if (maxKeysString != null) { try { maxKeys = Integer.parseInt(maxKeysString); } catch (NumberFormatException nfe) { throw new S3Exception(S3ErrorCode.INVALID_ARGUMENT, nfe); } if (maxKeys > 1000) { maxKeys = 1000; } } options.maxResults(maxKeys); response.setCharacterEncoding("UTF-8"); PageSet<? extends StorageMetadata> set = blobStore.list(containerName, options); try (Writer writer = response.getWriter()) { response.setStatus(HttpServletResponse.SC_OK); XMLStreamWriter xml = xmlOutputFactory.createXMLStreamWriter(writer); xml.writeStartDocument(); xml.writeStartElement("ListBucketResult"); xml.writeDefaultNamespace(AWS_XMLNS); writeSimpleElement(xml, "Name", containerName); if (prefix == null) { xml.writeEmptyElement("Prefix"); } else { writeSimpleElement(xml, "Prefix", encodeBlob(encodingType, prefix)); } writeSimpleElement(xml, "MaxKeys", String.valueOf(maxKeys)); if (marker == null) { xml.writeEmptyElement("Marker"); } else { writeSimpleElement(xml, "Marker", encodeBlob(encodingType, marker)); } if (delimiter != null) { writeSimpleElement(xml, "Delimiter", encodeBlob(encodingType, delimiter)); } if (encodingType != null && encodingType.equals("url")) { writeSimpleElement(xml, "EncodingType", encodingType); } String nextMarker = set.getNextMarker(); if (nextMarker != null) { writeSimpleElement(xml, "IsTruncated", "true"); writeSimpleElement(xml, "NextMarker", encodeBlob(encodingType, nextMarker)); if (Quirks.OPAQUE_MARKERS.contains(blobStoreType)) { lastKeyToMarker.put(Maps.immutableEntry(containerName, Iterables.getLast(set).getName()), nextMarker); } } else { writeSimpleElement(xml, "IsTruncated", "false"); } Set<String> commonPrefixes = new TreeSet<>(); for (StorageMetadata metadata : set) { switch (metadata.getType()) { case FOLDER: continue; case RELATIVE_PATH: commonPrefixes.add(metadata.getName()); continue; default: break; } xml.writeStartElement("Contents"); writeSimpleElement(xml, "Key", encodeBlob(encodingType, metadata.getName())); Date lastModified = metadata.getLastModified(); if (lastModified != null) { writeSimpleElement(xml, "LastModified", formatDate(lastModified)); } String eTag = metadata.getETag(); if (eTag != null) { writeSimpleElement(xml, "ETag", maybeQuoteETag(eTag)); } writeSimpleElement(xml, "Size", String.valueOf(metadata.getSize())); writeSimpleElement(xml, "StorageClass", "STANDARD"); writeOwnerStanza(xml); xml.writeEndElement(); } for (String commonPrefix : commonPrefixes) { xml.writeStartElement("CommonPrefixes"); writeSimpleElement(xml, "Prefix", encodeBlob(encodingType, commonPrefix)); xml.writeEndElement(); } xml.writeEndElement(); xml.flush(); } catch (XMLStreamException xse) { throw new IOException(xse); } }