List of usage examples for javax.xml.stream XMLStreamWriter writeEndDocument
public void writeEndDocument() throws XMLStreamException;
From source file:org.apache.nifi.authorization.FileAccessPolicyProvider.java
@Override public String getFingerprint() throws AuthorizationAccessException { final List<AccessPolicy> policies = new ArrayList<>(getAccessPolicies()); Collections.sort(policies, Comparator.comparing(AccessPolicy::getIdentifier)); XMLStreamWriter writer = null; final StringWriter out = new StringWriter(); try {/* www . ja va 2s. c o m*/ writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement("accessPolicies"); for (AccessPolicy policy : policies) { writePolicy(writer, policy); } writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); } catch (XMLStreamException e) { throw new AuthorizationAccessException("Unable to generate fingerprint", e); } finally { if (writer != null) { try { writer.close(); } catch (XMLStreamException e) { // nothing to do here } } } return out.toString(); }
From source file:org.apache.nifi.authorization.FileUserGroupProvider.java
@Override public String getFingerprint() throws AuthorizationAccessException { final UserGroupHolder usersAndGroups = userGroupHolder.get(); final List<User> users = new ArrayList<>(usersAndGroups.getAllUsers()); Collections.sort(users, Comparator.comparing(User::getIdentifier)); final List<Group> groups = new ArrayList<>(usersAndGroups.getAllGroups()); Collections.sort(groups, Comparator.comparing(Group::getIdentifier)); XMLStreamWriter writer = null; final StringWriter out = new StringWriter(); try {/*w w w.ja va 2s . co m*/ writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement("tenants"); for (User user : users) { writeUser(writer, user); } for (Group group : groups) { writeGroup(writer, group); } writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); } catch (XMLStreamException e) { throw new AuthorizationAccessException("Unable to generate fingerprint", e); } finally { if (writer != null) { try { writer.close(); } catch (XMLStreamException e) { // nothing to do here } } } return out.toString(); }
From source file:org.apache.nifi.authorization.StandardManagedAuthorizer.java
@Override public String getFingerprint() throws AuthorizationAccessException { XMLStreamWriter writer = null; final StringWriter out = new StringWriter(); try {// w w w. ja v a 2s . c om writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement("managedAuthorizations"); writer.writeStartElement(ACCESS_POLICY_PROVIDER_ELEMENT); if (accessPolicyProvider instanceof ConfigurableAccessPolicyProvider) { writer.writeCharacters(((ConfigurableAccessPolicyProvider) accessPolicyProvider).getFingerprint()); } writer.writeEndElement(); writer.writeStartElement(USER_GROUP_PROVIDER_ELEMENT); if (userGroupProvider instanceof ConfigurableUserGroupProvider) { writer.writeCharacters(((ConfigurableUserGroupProvider) userGroupProvider).getFingerprint()); } writer.writeEndElement(); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); } catch (XMLStreamException e) { throw new AuthorizationAccessException("Unable to generate fingerprint", e); } finally { if (writer != null) { try { writer.close(); } catch (XMLStreamException e) { // nothing to do here } } } return out.toString(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void property(final Writer outWriter, final Property property) throws XMLStreamException, EdmPrimitiveTypeException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); writer.writeStartDocument();/* w w w .j ava 2 s .co m*/ property(writer, property); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entity(final Writer outWriter, final Entity entity) throws XMLStreamException, EdmPrimitiveTypeException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); if (entity.getType() == null && entity.getProperties().isEmpty()) { writer.writeStartDocument();//from w ww . j a va2 s.co m writer.setDefaultNamespace(namespaceMetadata); entityRef(writer, entity); } else { startDocument(writer, Constants.ATOM_ELEM_ENTRY); entity(writer, entity); } writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entity(final Writer outWriter, final ResWrap<Entity> container) throws XMLStreamException, EdmPrimitiveTypeException { final Entity entity = container.getPayload(); final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); if (entity.getType() == null && entity.getProperties().isEmpty()) { writer.writeStartDocument();/*w w w . ja v a 2 s . c om*/ writer.setDefaultNamespace(namespaceMetadata); entityRef(writer, container); } else { startDocument(writer, Constants.ATOM_ELEM_ENTRY); addContextInfo(writer, container); entity(writer, entity); } writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entitySet(final Writer outWriter, final EntityCollection entitySet) throws XMLStreamException, EdmPrimitiveTypeException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); startDocument(writer, Constants.ATOM_ELEM_FEED); entitySet(writer, entitySet);//ww w. j a va 2s .com writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void entitySet(final Writer outWriter, final ResWrap<EntityCollection> entitySet) throws XMLStreamException, EdmPrimitiveTypeException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); startDocument(writer, Constants.ATOM_ELEM_FEED); addContextInfo(writer, entitySet);//from w w w . ja v a 2 s . c om entitySet(writer, entitySet.getPayload()); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void link(final Writer outWriter, final Link link) throws XMLStreamException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); writer.writeStartDocument();/*from ww w .j a va 2 s . c o m*/ writer.writeStartElement(Constants.ELEM_LINKS); writer.writeDefaultNamespace(namespaceData); writer.writeStartElement(Constants.ELEM_URI); writer.writeCharacters(link.getHref()); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); }
From source file:org.apache.olingo.client.core.serialization.AtomSerializer.java
private void reference(final Writer outWriter, final ResWrap<URI> container) throws XMLStreamException { final XMLStreamWriter writer = FACTORY.createXMLStreamWriter(outWriter); writer.writeStartDocument();//from ww w .j a va2s. co m writer.writeStartElement(Constants.ATTR_METADATA, Constants.ATTR_REF, Constants.NS_METADATA); writer.writeNamespace(Constants.ATTR_METADATA, Constants.NS_METADATA); writer.writeAttribute(Constants.ATTR_METADATA, Constants.NS_METADATA, Constants.CONTEXT, container.getContextURL().toASCIIString()); writer.writeAttribute(Constants.ATOM_ATTR_ID, container.getPayload().toASCIIString()); writer.writeEndElement(); writer.writeEndDocument(); }