private String currentHandledStartTagName;
private static final String DEFAULT_PREFIX = "";
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);
}