@Test public void testServiceDocument() throws IOException, EntityProviderException { AtomServiceDocumentConsumer svcDocumentParser = new AtomServiceDocumentConsumer(); ServiceDocument svcDocument = svcDocumentParser.readServiceDokument(createStreamReader("/svcExample.xml")); assertNotNull(svcDocument); AtomInfo atomInfo = svcDocument.getAtomInfo(); assertNotNull(atomInfo); assertNotNull(atomInfo.getWorkspaces()); for (Workspace workspace : atomInfo.getWorkspaces()) { assertEquals("Data", workspace.getTitle().getText()); assertEquals(10, workspace.getCollections().size()); for (Collection collection : workspace.getCollections()) { assertNotNull(collection.getHref()); if ("TypeOneEntityCollection".equals(collection.getHref())) { assertEquals("TypeOneEntityCollection", collection.getTitle().getText()); assertFalse(collection.getCommonAttributes().getAttributes().isEmpty()); assertEquals("content-version", collection.getCommonAttributes().getAttributes().get(0).getName()); assertEquals(NAMESPACE, collection.getCommonAttributes().getAttributes().get(0).getNamespace()); assertEquals(PREFIX, collection.getCommonAttributes().getAttributes().get(0).getPrefix()); assertEquals("1", collection.getCommonAttributes().getAttributes().get(0).getText()); assertFalse(collection.getExtesionElements().isEmpty()); for (ExtensionElement extElement : collection.getExtesionElements()) { assertEquals(PREFIX, extElement.getPrefix()); assertEquals("member-title", extElement.getName()); assertEquals(NAMESPACE, extElement.getNamespace()); } } } } }
public ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader) throws EntityProviderException { AtomInfoImpl atomInfo = new AtomInfoImpl(); ServiceDocumentImpl serviceDocument = new ServiceDocumentImpl(); List<Workspace> workspaces = new ArrayList<Workspace>(); List<ExtensionElement> extElements = new ArrayList<ExtensionElement>(); CommonAttributesImpl attributes = new CommonAttributesImpl(); try { while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI()) && FormatXml.APP_SERVICE .equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { currentHandledStartTagName = reader.getLocalName(); if (FormatXml.APP_SERVICE.equals(currentHandledStartTagName)) { attributes = parseCommonAttribute(reader); } else if (FormatXml.APP_WORKSPACE.equals(currentHandledStartTagName)) { workspaces.add(parseWorkspace(reader)); } else { ExtensionElementImpl extElement = parseExtensionElement(reader); if (extElement != null) { extElements.add(extElement); } } } } if (workspaces.isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE .addContent("Service element must contain at least one workspace element")); } reader.close(); atomInfo.setWorkspaces(workspaces).setCommonAttributes(attributes).setExtesionElements(extElements); serviceDocument.setAtomInfo(atomInfo); serviceDocument.setEntitySetsInfo(atomInfo.getEntitySetsInfo()); return serviceDocument; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
AtomServiceDocumentConsumer { public ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader) throws EntityProviderException { AtomInfoImpl atomInfo = new AtomInfoImpl(); ServiceDocumentImpl serviceDocument = new ServiceDocumentImpl(); List<Workspace> workspaces = new ArrayList<Workspace>(); List<ExtensionElement> extElements = new ArrayList<ExtensionElement>(); CommonAttributesImpl attributes = new CommonAttributesImpl(); try { while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI()) && FormatXml.APP_SERVICE .equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { currentHandledStartTagName = reader.getLocalName(); if (FormatXml.APP_SERVICE.equals(currentHandledStartTagName)) { attributes = parseCommonAttribute(reader); } else if (FormatXml.APP_WORKSPACE.equals(currentHandledStartTagName)) { workspaces.add(parseWorkspace(reader)); } else { ExtensionElementImpl extElement = parseExtensionElement(reader); if (extElement != null) { extElements.add(extElement); } } } } if (workspaces.isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE .addContent("Service element must contain at least one workspace element")); } reader.close(); atomInfo.setWorkspaces(workspaces).setCommonAttributes(attributes).setExtesionElements(extElements); serviceDocument.setAtomInfo(atomInfo); serviceDocument.setEntitySetsInfo(atomInfo.getEntitySetsInfo()); return serviceDocument; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } } }
AtomServiceDocumentConsumer { public ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader) throws EntityProviderException { AtomInfoImpl atomInfo = new AtomInfoImpl(); ServiceDocumentImpl serviceDocument = new ServiceDocumentImpl(); List<Workspace> workspaces = new ArrayList<Workspace>(); List<ExtensionElement> extElements = new ArrayList<ExtensionElement>(); CommonAttributesImpl attributes = new CommonAttributesImpl(); try { while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI()) && FormatXml.APP_SERVICE .equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { currentHandledStartTagName = reader.getLocalName(); if (FormatXml.APP_SERVICE.equals(currentHandledStartTagName)) { attributes = parseCommonAttribute(reader); } else if (FormatXml.APP_WORKSPACE.equals(currentHandledStartTagName)) { workspaces.add(parseWorkspace(reader)); } else { ExtensionElementImpl extElement = parseExtensionElement(reader); if (extElement != null) { extElements.add(extElement); } } } } if (workspaces.isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE .addContent("Service element must contain at least one workspace element")); } reader.close(); atomInfo.setWorkspaces(workspaces).setCommonAttributes(attributes).setExtesionElements(extElements); serviceDocument.setAtomInfo(atomInfo); serviceDocument.setEntitySetsInfo(atomInfo.getEntitySetsInfo()); return serviceDocument; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  }
AtomServiceDocumentConsumer { public ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader) throws EntityProviderException { AtomInfoImpl atomInfo = new AtomInfoImpl(); ServiceDocumentImpl serviceDocument = new ServiceDocumentImpl(); List<Workspace> workspaces = new ArrayList<Workspace>(); List<ExtensionElement> extElements = new ArrayList<ExtensionElement>(); CommonAttributesImpl attributes = new CommonAttributesImpl(); try { while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI()) && FormatXml.APP_SERVICE .equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { currentHandledStartTagName = reader.getLocalName(); if (FormatXml.APP_SERVICE.equals(currentHandledStartTagName)) { attributes = parseCommonAttribute(reader); } else if (FormatXml.APP_WORKSPACE.equals(currentHandledStartTagName)) { workspaces.add(parseWorkspace(reader)); } else { ExtensionElementImpl extElement = parseExtensionElement(reader); if (extElement != null) { extElements.add(extElement); } } } } if (workspaces.isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE .addContent("Service element must contain at least one workspace element")); } reader.close(); atomInfo.setWorkspaces(workspaces).setCommonAttributes(attributes).setExtesionElements(extElements); serviceDocument.setAtomInfo(atomInfo); serviceDocument.setEntitySetsInfo(atomInfo.getEntitySetsInfo()); return serviceDocument; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader); ServiceDocumentImpl parseXml(final InputStream in); }
AtomServiceDocumentConsumer { public ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader) throws EntityProviderException { AtomInfoImpl atomInfo = new AtomInfoImpl(); ServiceDocumentImpl serviceDocument = new ServiceDocumentImpl(); List<Workspace> workspaces = new ArrayList<Workspace>(); List<ExtensionElement> extElements = new ArrayList<ExtensionElement>(); CommonAttributesImpl attributes = new CommonAttributesImpl(); try { while (reader.hasNext() && !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI()) && FormatXml.APP_SERVICE .equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { currentHandledStartTagName = reader.getLocalName(); if (FormatXml.APP_SERVICE.equals(currentHandledStartTagName)) { attributes = parseCommonAttribute(reader); } else if (FormatXml.APP_WORKSPACE.equals(currentHandledStartTagName)) { workspaces.add(parseWorkspace(reader)); } else { ExtensionElementImpl extElement = parseExtensionElement(reader); if (extElement != null) { extElements.add(extElement); } } } } if (workspaces.isEmpty()) { throw new EntityProviderException(EntityProviderException.INVALID_STATE .addContent("Service element must contain at least one workspace element")); } reader.close(); atomInfo.setWorkspaces(workspaces).setCommonAttributes(attributes).setExtesionElements(extElements); serviceDocument.setAtomInfo(atomInfo); serviceDocument.setEntitySetsInfo(atomInfo.getEntitySetsInfo()); return serviceDocument; } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  ServiceDocumentImpl readServiceDokument(final XMLStreamReader reader); ServiceDocumentImpl parseXml(final InputStream in);  }