chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1297943 [1/2] - in /chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis: client/bindings/spi/atompub/ commons/impl/
Date Wed, 07 Mar 2012 11:27:17 GMT
Author: fmui
Date: Wed Mar  7 11:27:16 2012
New Revision: 1297943

URL: http://svn.apache.org/viewvc?rev=1297943&view=rev
Log:
Android code update

Modified:
    chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
    chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java
    chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java
    chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/commons/impl/AtomPubConverter.java

Modified: chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java?rev=1297943&r1=1297942&r2=1297943&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java Wed Mar  7 11:27:16 2012
@@ -34,6 +34,7 @@ import static org.apache.chemistry.openc
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.text.SimpleDateFormat;
@@ -45,6 +46,7 @@ import java.util.TimeZone;
 
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.PropertyBoolean;
 import org.apache.chemistry.opencmis.commons.data.PropertyData;
@@ -251,6 +253,11 @@ public class AtomEntryWriter {
         if (object.getProperties() != null) {
             writer.startTag(Constants.NAMESPACE_CMIS, Constants.SELECTOR_PROPERTIES);
             writeProperties(writer, object.getProperties().getPropertyList());
+            
+            if (object.getProperties().getExtensions() != null && object.getProperties().getExtensions().isEmpty() == false){
+            	writeExtensions(writer, object.getProperties().getExtensions());
+            }
+            
             writer.endTag(Constants.NAMESPACE_CMIS, Constants.SELECTOR_PROPERTIES);
         }
         writer.endTag(Constants.NAMESPACE_RESTATOM, Constants.SELECTOR_OBJECT);
@@ -282,6 +289,25 @@ public class AtomEntryWriter {
         writeValues(writer, prop.getValues());
         writer.endTag(Constants.NAMESPACE_CMIS, getPropertyTypeTag(prop));
     }
+    
+    private static void writeExtensions(XmlSerializer writer, List<CmisExtensionElement> extensions) throws Exception{
+    	for (CmisExtensionElement cmisExtensionElement : extensions) {
+    		writer.startTag(cmisExtensionElement.getNamespace(), cmisExtensionElement.getName());
+    		writeAttributes(writer, cmisExtensionElement.getAttributes());
+    		if (cmisExtensionElement.getChildren() != null && cmisExtensionElement.getChildren().isEmpty() == false){
+    			writeExtensions(writer, cmisExtensionElement.getChildren());
+    		} else if (cmisExtensionElement.getValue() != null){
+    			writer.text(cmisExtensionElement.getValue());
+    		}
+            writer.endTag(cmisExtensionElement.getNamespace(), cmisExtensionElement.getName());
+		}
+    }
+    
+    private static void writeAttributes(XmlSerializer writer,  Map<String, String> values) throws Exception{
+    	for (Map.Entry<String, String> value : values.entrySet()) {
+            writer.attribute(null, value.getKey(), value.getValue());
+		}
+    }
 
     private static void writeValues(XmlSerializer writer, List<?> values) throws Exception {
         for (Object value : values) {

Modified: chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java?rev=1297943&r1=1297942&r2=1297943&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java Wed Mar  7 11:27:16 2012
@@ -59,15 +59,17 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_TYPE;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_URI_TEMPLATE;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_WORKSPACE;
-
+import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_REPINFO_ACL_CAPABILITY;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.ATTR_PROPERTY_DEFINITION_ID;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_RENDITION;
-import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ACLCAP_ACL;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ACLCAP_MAPPING;
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ACE_DIRECT;
 
 import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_PROPERTY;
-
+import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_OBJECT_PROPERTIES;
+import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_OBJECT_ALLOWABLE_ACTIONS;
+import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_OBJECT_ACL;
+import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_OBJECT_RENDITIONS;
 
 
 import java.io.IOException;
@@ -77,6 +79,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Stack;
 
 import javax.xml.namespace.QName;
 
@@ -93,6 +96,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
 import org.apache.chemistry.opencmis.commons.data.Properties;
@@ -109,6 +113,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionDefinitionDataImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionMappingDataImpl;
 import org.xmlpull.v1.XmlPullParser;
@@ -121,959 +126,1117 @@ import android.util.Xml;
  */
 public class AtomPubParser {
 
-    // public constants
-    public static final String LINK_REL_CONTENT = "@@content@@";
+	// public constants
+	public static final String LINK_REL_CONTENT = "@@content@@";
 
-    private final InputStream stream;
-    private AtomBase parseResult;
+	private final InputStream stream;
+	private AtomBase parseResult;
 
-    public AtomPubParser(InputStream stream) {
-        if (stream == null) {
-            throw new IllegalArgumentException("No stream.");
-        }
-
-        this.stream = stream;
-    }
-
-    /**
-     * Parses the stream.
-     */
-    public void parse() throws Exception {
-        XmlPullParser parser = Xml.newPullParser();
-        parser.setInput(stream, null);
-
-        try {
-            while (true) {
-                int event = parser.getEventType();
-                if (event == XmlPullParser.START_TAG) {
-                    QName name = new QName(parser.getNamespace(), parser.getName());
-
-                    if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
-                        if (TAG_FEED.equals(name.getLocalPart())) {
-                            parseResult = parseFeed(parser);
-                            break;
-                        } else if (TAG_ENTRY.equals(name.getLocalPart())) {
-                            parseResult = parseEntry(parser);
-                            break;
-                        }
-                    } else if (Constants.NAMESPACE_CMIS.equals(name.getNamespaceURI())) {
-                        if (TAG_ALLOWABLEACTIONS.equals(name.getLocalPart())) {
-                            parseResult = new AtomAllowableActions(parseAllowableActions(parser));
-                            break;
-                        } else if (TAG_ACL.equals(name.getLocalPart())) {
-                            parseResult = new AtomAcl(parseACL(parser));
-                            break;
-                        }
-                    } else if (Constants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
-                        if (TAG_SERVICE.equals(name.getLocalPart())) {
-                            parseResult = parseServiceDoc(parser);
-                            break;
-                        }
-                    }
-                }
-
-                if (!next(parser)) {
-                    break;
-                }
-            }
-
-        } finally {
-            // make sure the stream is read and closed in all cases
-            try {
-                byte[] buffer = new byte[4096];
-                while (stream.read(buffer) > -1) {
-                }
-            } catch (Exception e) {
-            }
-
-            try {
-                stream.close();
-            } catch (Exception e) {
-            }
-        }
-    }
-
-    /**
-     * Return the parse results.
-     */
-    public AtomBase getResults() {
-        return parseResult;
-    }
-
-    /**
-     * Parses a service document.
-     */
-    private static ServiceDoc parseServiceDoc(XmlPullParser parser) throws Exception {
-        ServiceDoc result = new ServiceDoc();
-
-        next(parser);
-
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                QName name = new QName(parser.getNamespace(), parser.getName());
-
-                if (Constants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
-                    if (TAG_WORKSPACE.equals(name.getLocalPart())) {
-                        result.addWorkspace(parseWorkspace(parser));
-                    } else {
-                        skip(parser);
-                    }
-                } else {
-                    skip(parser);
-                }
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        return result;
-    }
-
-    /**
-     * Parses a workspace element in a service document.
-     */
-    private static RepositoryWorkspace parseWorkspace(XmlPullParser parser) throws Exception {
-        RepositoryWorkspace workspace = new RepositoryWorkspace();
-
-        next(parser);
-
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                AtomElement element = parseWorkspaceElement(parser);
-
-                // check if we can extract the workspace id
-                if ((element != null) && (element.getObject() instanceof RepositoryInfo)) {
-                    workspace.setId(((RepositoryInfo) element.getObject()).getId());
-                }
-
-                // add to workspace
-                workspace.addElement(element);
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-
-        return workspace;
-    }
-
-    /**
-     * Parses an Atom feed.
-     */
-    private AtomFeed parseFeed(XmlPullParser parser) throws Exception {
-        AtomFeed result = new AtomFeed();
-
-        next(parser);
-
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                QName name = new QName(parser.getNamespace(), parser.getName());
-
-                if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
-                    if (TAG_LINK.equals(name.getLocalPart())) {
-                        result.addElement(parseLink(parser));
-                    } else if (TAG_ENTRY.equals(name.getLocalPart())) {
-                        result.addEntry(parseEntry(parser));
-                    } else {
-                        skip(parser);
-                    }
-                } else if (Constants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
-                    if (TAG_NUM_ITEMS.equals(name.getLocalPart())) {
-                        result.addElement(parseBigInteger(parser));
-                    } else {
-                        skip(parser);
-                    }
-                } else {
-                    skip(parser);
-                }
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-
-        return result;
-    }
-
-    /**
-     * Parses an Atom entry.
-     */
-    private AtomEntry parseEntry(XmlPullParser parser) throws Exception {
-        AtomEntry result = new AtomEntry();
-
-        next(parser);
-
-        // walk through all tags in entry
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                AtomElement element = parseElement(parser);
-                if (element != null) {
-                    // add to entry
-                    result.addElement(element);
-
-                    // find and set object id
-                    if (element.getObject() instanceof ObjectData) {
-                        result.setId(((ObjectData) element.getObject()).getId());
-                    } else if (element.getObject() instanceof TypeDefinition) {
-                        result.setId(((TypeDefinition) element.getObject()).getId());
-                    }
-                }
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-
-        return result;
-    }
-
-    /**
-     * Parses an element.
-     */
-    private AtomElement parseElement(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-
-        if (Constants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
-            if (TAG_OBJECT.equals(name.getLocalPart())) {
-                return new AtomElement(name, parseObject(parser));
-            } else if (TAG_PATH_SEGMENT.equals(name.getLocalPart())
-                    || TAG_RELATIVE_PATH_SEGMENT.equals(name.getLocalPart())) {
-                return parseText(parser);
-            } else if (TAG_TYPE.equals(name.getLocalPart())) {
-                // workaround for old Chemistry code - ignore the type namespace
-                String typeAttr = parser.getAttributeValue(Constants.NAMESPACE_XSI, "type");
-                if (typeAttr == null) {
-                    return new AtomElement(name, parseTypeDefinition(parser, null));
-                } else if (typeAttr.endsWith(ATTR_DOCUMENT_TYPE)) {
-                    return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_DOCUMENT));
-                } else if (typeAttr.endsWith(ATTR_FOLDER_TYPE)) {
-                    return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_FOLDER));
-                } else if (typeAttr.endsWith(ATTR_RELATIONSHIP_TYPE)) {
-                    return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_RELATIONSHIP));
-                } else if (typeAttr.endsWith(ATTR_POLICY_TYPE)) {
-                    return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_POLICY));
-                }
-                throw new CmisRuntimeException("Cannot read type definition!");
-            } else if (TAG_CHILDREN.equals(name.getLocalPart())) {
-                return parseChildren(parser);
-            }
-        } else if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
-            if (TAG_LINK.equals(name.getLocalPart())) {
-                return parseLink(parser);
-            } else if (TAG_CONTENT.equals(name.getLocalPart())) {
-                return parseAtomContentSrc(parser);
-            }
-        }
-
-        // we don't know it - skip it
-        skip(parser);
-
-        return null;
-    }
-
-    /**
-     * Parses a children element.
-     */
-    private AtomElement parseChildren(XmlPullParser parser) throws Exception {
-        AtomElement result = null;
-        QName childName = new QName(parser.getNamespace(), parser.getName());
-
-        next(parser);
-
-        // walk through the children tag
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                QName name = new QName(parser.getNamespace(), parser.getName());
-
-                if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
-                    if (TAG_FEED.equals(name.getLocalPart())) {
-                        result = new AtomElement(childName, parseFeed(parser));
-                    } else {
-                        skip(parser);
-                    }
-                } else {
-                    skip(parser);
-                }
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-
-        return result;
-    }
-
-    /**
-     * Parses a workspace element.
-     */
-    private static AtomElement parseWorkspaceElement(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-
-        if (Constants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
-            if (TAG_REPOSITORY_INFO.equals(name.getLocalPart())) {
-                return new AtomElement(name, parseRepositoryInfo(parser));
-            } else if (TAG_URI_TEMPLATE.equals(name.getLocalPart())) {
-                return parseTemplate(parser);
-            }
-        } else if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
-            if (TAG_LINK.equals(name.getLocalPart())) {
-                return parseLink(parser);
-            }
-        } else if (Constants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
-            if (TAG_COLLECTION.equals(name.getLocalPart())) {
-                return parseCollection(parser);
-            }
-        }
-
-        // we don't know it - skip it
-        skip(parser);
-
-        return null;
-    }
-
-    /**
-     * Parses a collection tag.
-     */
-    private static AtomElement parseCollection(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-        Map<String, String> result = new HashMap<String, String>();
-
-        result.put("href", parser.getAttributeValue(null, "href"));
-
-        next(parser);
-
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                QName tagName = new QName(parser.getNamespace(), parser.getName());
-                if (Constants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI())
-                        && TAG_COLLECTION_TYPE.equals(tagName.getLocalPart())) {
-                    result.put("collectionType", readText(parser));
-                } else {
-                    skip(parser);
-                }
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-
-        return new AtomElement(name, result);
-    }
-
-    /**
-     * Parses a template tag.
-     */
-    private static AtomElement parseTemplate(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-        Map<String, String> result = new HashMap<String, String>();
-
-        next(parser);
-
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                QName tagName = new QName(parser.getNamespace(), parser.getName());
-                if (Constants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI())) {
-                    if (TAG_TEMPLATE_TEMPLATE.equals(tagName.getLocalPart())) {
-                        result.put("template", readText(parser));
-                    } else if (TAG_TEMPLATE_TYPE.equals(tagName.getLocalPart())) {
-                        result.put("type", readText(parser));
-                    } else {
-                        skip(parser);
-                    }
-                } else {
-                    skip(parser);
-                }
-            } else if (event == XmlPullParser.END_TAG) {
-                break;
-            } else {
-                if (!next(parser)) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-
-        return new AtomElement(name, result);
-    }
-
-    /**
-     * Parses a link tag.
-     */
-    private static AtomElement parseLink(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-        AtomLink result = new AtomLink();
-
-        // save attributes
-        for (int i = 0; i < parser.getAttributeCount(); i++) {
-            if (LINK_REL.equals(parser.getAttributeName(i))) {
-                result.setRel(parser.getAttributeValue(i));
-            } else if (LINK_HREF.equals(parser.getAttributeName(i))) {
-                result.setHref(parser.getAttributeValue(i));
-            } else if (LINK_TYPE.equals(parser.getAttributeName(i))) {
-                result.setType(parser.getAttributeValue(i));
-            }
-        }
-
-        // skip enclosed tags, if any
-        skip(parser);
-
-        return new AtomElement(name, result);
-    }
-
-    /**
-     * Parses a link tag.
-     */
-    private static AtomElement parseAtomContentSrc(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-        AtomLink result = new AtomLink();
-        result.setRel(LINK_REL_CONTENT);
-
-        // save attributes
-        for (int i = 0; i < parser.getAttributeCount(); i++) {
-            if (CONTENT_SRC.equals(parser.getAttributeName(i))) {
-                result.setHref(parser.getAttributeValue(i));
-            }
-        }
-
-        // skip enclosed tags, if any
-        skip(parser);
-
-        return new AtomElement(name, result);
-    }
-
-    /**
-     * Parses a text tag.
-     */
-    private static AtomElement parseText(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-        return new AtomElement(name, readText(parser));
-    }
-
-    /**
-     * Parses a text tag and convert it into an integer.
-     */
-    private static AtomElement parseBigInteger(XmlPullParser parser) throws Exception {
-        QName name = new QName(parser.getNamespace(), parser.getName());
-        return new AtomElement(name, new BigInteger(readText(parser)));
-    }
-
-    /**
-     * Parses a tag that contains text.
-     */
-    private static String readText(XmlPullParser parser) throws Exception {
-        StringBuilder sb = new StringBuilder();
-
-        next(parser);
-
-        while (true) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.END_TAG) {
-                break;
-            } else if (event == XmlPullParser.TEXT) {
-                String s = parser.getText();
-                if (s != null) {
-                    sb.append(s);
-                }
-            } else if (event == XmlPullParser.START_TAG) {
-                throw new RuntimeException("Unexpected tag: " + parser.getName());
-            }
-
-            if (!next(parser)) {
-                break;
-            }
-        }
-
-        next(parser);
-
-        return sb.toString();
-    }
-
-    /**
-     * Skips a tag or subtree.
-     */
-    private static void skip(XmlPullParser parser) throws Exception {
-        int level = 1;
-        while (next(parser)) {
-            int event = parser.getEventType();
-            if (event == XmlPullParser.START_TAG) {
-                level++;
-            } else if (event == XmlPullParser.END_TAG) {
-                level--;
-                if (level == 0) {
-                    break;
-                }
-            }
-        }
-
-        next(parser);
-    }
-
-    private static boolean next(XmlPullParser parser) throws Exception {
-        parser.next();
-        return true;
-    }
-
-    // -----------------------------------------------------------------------------------
-    // ------------- NEW ANDROID METHOD
-    // -----------------------------------------------------------------------------------
-
-    private static RepositoryInfo parseRepositoryInfo(XmlPullParser parser) throws Exception {
-        int eventType = parser.getEventType();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-        Map<String, String> repositoryInfoRawValues = new HashMap<String, String>(15);
-        Map<String, String> repositoryCapabilitiesRawValues = new HashMap<String, String>(15);
-        AclCapabilities aclCapabilities = null;
-        List<String> changesOnType = new ArrayList<String>();
-
-        while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_REPOSITORY_INFO.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (TAG_REPINFO_CAPABILITIES.equals(name)) {
-                    eventType = parser.next();
-                    name = parser.getName();
-                    while (!(eventType == XmlPullParser.END_TAG && TAG_REPINFO_CAPABILITIES.equals(name))) {
-                        switch (eventType) {
-                        case XmlPullParser.START_TAG:
-                            parser.next();
-                            repositoryCapabilitiesRawValues.put(name, parser.getText());
-                            break;
-                        }
-                        eventType = parser.next();
-                        name = parser.getName();
-                    }
-                } else if (TAG_ACLCAP_ACL.equals(name)) {
-                    aclCapabilities = parseAclCapabilities(parser);
-                } else if (TAG_REPINFO_CHANGES_ON_TYPE.equals(name)) {
-                    parser.next();
-                    changesOnType.add(parser.getText());
-                } else if (Constants.NAMESPACE_CMIS.equals(namespace)) {
-                    parser.next();
-                    repositoryInfoRawValues.put(name, parser.getText());
-                }
-
-                break;
-
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        parser.next();
-        return AtomPubConverter.convertRepositoryInfo(repositoryInfoRawValues, repositoryCapabilitiesRawValues,
-                aclCapabilities, changesOnType);
-    }
-
-    private static TypeDefinition parseTypeDefinition(XmlPullParser parser, BaseTypeId type) throws Exception {
-        Map<String, String> definitionRawValues = new HashMap<String, String>(15);
-        List<PropertyDefinition<?>> propertyDefinitionList = new ArrayList<PropertyDefinition<?>>(10);
-
-        int eventType = parser.getEventType();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-
-        while (!(eventType == XmlPullParser.END_TAG && TAG_TEMPLATE_TYPE.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (name.startsWith(TAG_PROPERTY)) {
-                    propertyDefinitionList.add(parsePropertyDefinition(parser));
-                } else if (Constants.NAMESPACE_CMIS.equals(namespace)) {
-                    parser.next();
-                    definitionRawValues.put(name, parser.getText());
-                }
-
-                break;
-
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        parser.next();
-        return AtomPubConverter.convertTypeDefinition(type, definitionRawValues, propertyDefinitionList);
-    }
-
-    private static PropertyDefinition<?> parsePropertyDefinition(XmlPullParser parser) throws Exception {
-        String id = null;
-        Map<String, String> propertyTypeRawValues = new HashMap<String, String>(15);
-        id = parser.getName();
-        int eventType = parser.next();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-
-        while (!(eventType == XmlPullParser.END_TAG && id.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (Constants.NAMESPACE_CMIS.equals(namespace)) {
-                    parser.next();
-                    propertyTypeRawValues.put(name, parser.getText());
-                }
-                break;
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        return AtomPubConverter.convertPropertyDefinition(id, propertyTypeRawValues);
-    }
-
-    public static ObjectData parseObject(XmlPullParser parser) throws Exception {
-        List<RenditionData> renditions = new ArrayList<RenditionData>(3);
-        Properties properties = null;
-        AllowableActions allowableActions = null;
-        Acl acl = null;
-
-        int eventType = parser.getEventType();
-        String name = parser.getName();
-
-        while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_OBJECT.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (name.startsWith(TAG_PROPERTY)) {
-                    properties = parseProperties(parser);
-                } else if (Constants.SELECTOR_ALLOWABLEACTIONS.equals(name)) {
-                    allowableActions = parseAllowableActions(parser);
-                } else if (Constants.SELECTOR_ACL.equals(name)) {
-                    acl = parseACL(parser);
-                } else if (Constants.SELECTOR_RENDITIONS.equals(name)) {
-                    renditions.add(parseRenditions(parser));
-                }
-                break;
-
-            }
-            eventType = parser.next();
-            name = parser.getName();
-        }
-
-        // Important !
-        parser.next();
-
-        return AtomPubConverter.convertObject(properties, allowableActions, acl, renditions);
-    }
-
-    /**
-     * Converts properties.
-     * 
-     * @throws IOException
-     * @throws XmlPullParserException
-     */
-    public static Properties parseProperties(XmlPullParser parser) throws Exception {
-        if (parser == null) {
-            return null;
-        }
-
-        int eventType = parser.getEventType();
-        String name = parser.getName();
-        String nameSpace = parser.getNamespace();
-        int countParam = 0;
-        String id = null, displayName = null, queryName = null, localName = null, paramName = null, tag = null;
-        List<String> values = null;
-        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
-
-        while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_PROPERTIES.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-
-                // Extension skip data
-                if (!Constants.NAMESPACE_CMIS.equals(nameSpace)) {
-                    skip(parser);
-                    eventType = parser.getEventType();
-                    name = parser.getName();
-                    nameSpace = parser.getNamespace();
-                    continue;
-                }
-
-                tag = name;
-
-                // attributes
-                countParam = parser.getAttributeCount();
-                displayName = null;
-                queryName = null;
-                localName = null;
-                paramName = null;
-                for (int i = 0; i < countParam; i++) {
-                    paramName = parser.getAttributeName(i);
-                    if (ATTR_PROPERTY_DISPLAYNAME.equals(paramName)) {
-                        displayName = parser.getAttributeValue(i);
-                    } else if (ATTR_PROPERTY_QUERYNAME.equals(paramName)) {
-                        queryName = parser.getAttributeValue(i);
-                    } else if (ATTR_PROPERTY_LOCALNAME.equals(paramName)) {
-                        localName = parser.getAttributeValue(i);
-                    } else if (ATTR_PROPERTY_DEFINITION_ID.equals(paramName)) {
-                        id = parser.getAttributeValue(i);
-                    }
-                }
-
-                // Values
-                values = new ArrayList<String>(2);
-                while (!(eventType == XmlPullParser.END_TAG && tag.equals(name))) {
-                    switch (eventType) {
-                    case XmlPullParser.START_TAG:
-                        if (ATTR_PROPERTY_VALUE.equals(name)) {
-                            parser.next();
-                            values.add(parser.getText());
-                        }
-                        break;
-                    }
-                    eventType = parser.next();
-                    name = parser.getName();
-                }
-
-                // Convert
-                properties.add(AtomPubConverter.convertProperty(tag, id, displayName, queryName, localName, values));
-                break;
-
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            nameSpace = parser.getNamespace();
-        }
-        return AtomPubConverter.convertProperties(properties);
-    }
-
-    public static RenditionData parseRenditions(XmlPullParser parser) throws Exception {
-        Map<String, String> rendition = new HashMap<String, String>(15);
-        int eventType = parser.next();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-
-        while (!(eventType == XmlPullParser.END_TAG && TAG_RENDITION.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (Constants.NAMESPACE_CMIS.equals(namespace)) {
-                    parser.next();
-                    rendition.put(name, parser.getText());
-                }
-                break;
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        return AtomPubConverter.convertRendition(rendition);
-    }
-
-    public static AllowableActions parseAllowableActions(XmlPullParser parser) throws Exception {
-        Map<String, String> allowableActionsRawValues = new HashMap<String, String>(15);
-        int eventType = parser.next();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-
-        while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_ALLOWABLEACTIONS.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (Constants.NAMESPACE_CMIS.equals(namespace)) {
-                    parser.next();
-                    allowableActionsRawValues.put(name, parser.getText());
-                }
-                break;
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        return AtomPubConverter.convertAllowableActions(allowableActionsRawValues);
-    }
-
-    public static AclCapabilities parseAclCapabilities(XmlPullParser parser) throws Exception {
-        Map<String, String> AclCapabilitiesRawValues = new HashMap<String, String>(15);
-        List<PermissionDefinition> permissionDefinitionList = new ArrayList<PermissionDefinition>();
-        Map<String, PermissionMapping> permMap = new HashMap<String, PermissionMapping>();
-
-        int eventType = parser.next();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-
-        while (!(eventType == XmlPullParser.END_TAG && TAG_ACLCAP_ACL.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_PERMISSIONS.equals(name)) {
-
-                    String permission = null, description = null;
-                    // Permissions
-                    while (!(eventType == XmlPullParser.END_TAG && TAG_ACLCAP_PERMISSIONS.equals(name))) {
-                        switch (eventType) {
-                        case XmlPullParser.START_TAG:
-                            if (Constants.NAMESPACE_CMIS.equals(namespace)
-                                    && TAG_ACLCAP_PERMISSION_PERMISSION.equals(name)) {
-                                parser.next();
-                                permission = parser.getText();
-                            } else if (Constants.NAMESPACE_CMIS.equals(namespace)
-                                    && TAG_ACLCAP_PERMISSION_DESCRIPTION.equals(name)) {
-                                parser.next();
-                                description = parser.getText();
-                            }
-                            break;
-                        }
-                        eventType = parser.next();
-                        name = parser.getName();
-                    }
-                    PermissionDefinitionDataImpl permDef = new PermissionDefinitionDataImpl();
-                    permDef.setPermission(permission);
-                    permDef.setDescription(description);
-
-                    // convertExtension(permissionMap, permDef,
-                    // ACLCAP_PERMISSION_KEYS);
-
-                    permissionDefinitionList.add(permDef);
-
-                } else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_MAPPING.equals(name)) {
-
-                    String key = null;
-                    List<String> permList = new ArrayList<String>();
-                    // MAPPINGS
-                    while (!(eventType == XmlPullParser.END_TAG && TAG_ACLCAP_MAPPING.equals(name))) {
-                        switch (eventType) {
-                        case XmlPullParser.START_TAG:
-                            if (Constants.NAMESPACE_CMIS.equals(namespace)
-                                    && TAG_ACLCAP_MAPPING_KEY.equals(name)) {
-                                parser.next();
-                                key = parser.getText();
-                            } else if (Constants.NAMESPACE_CMIS.equals(namespace)
-                                    && TAG_ACLCAP_MAPPING_PERMISSION.equals(name)) {
-                                parser.next();
-                                permList.add(parser.getText());
-                            }
-                            break;
-                        }
-                        eventType = parser.next();
-                        name = parser.getName();
-                    }
-                    PermissionMappingDataImpl mapping = new PermissionMappingDataImpl();
-                    mapping.setKey(key);
-                    mapping.setPermissions(permList);
-
-                    // convertExtension(permissionMap, mapping,
-                    // ACLCAP_MAPPING_KEYS);
-
-                    permMap.put(key, mapping);
-
-                } else if (Constants.NAMESPACE_CMIS.equals(namespace)) {
-                    parser.next();
-                    AclCapabilitiesRawValues.put(name, parser.getText());
-                }
-                break;
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        return AtomPubConverter.convertAclCapabilities(AclCapabilitiesRawValues, permissionDefinitionList, permMap);
-    }
-
-    private static Acl parseACL(XmlPullParser parser) throws Exception {
-        int eventType = parser.next();
-        String name = parser.getName();
-        String namespace = parser.getNamespace();
-        boolean isPermissionRootTag = false;
-        List<Ace> aces = new ArrayList<Ace>();
-        List<String> permissions = null;
-        AccessControlEntryImpl ace = null;
-
-        while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_ACL.equals(name))) {
-            switch (eventType) {
-            case XmlPullParser.START_TAG:
-                if (Constants.NAMESPACE_CMIS.equals(namespace)
-                        && TAG_ACLCAP_PERMISSION_PERMISSION.equals(name)) {
-                    if (isPermissionRootTag == false) {
-                        isPermissionRootTag = true;
-                        permissions = new ArrayList<String>();
-                        ace = new AccessControlEntryImpl();
-                    } else {
-                        parser.next();
-                        permissions.add(parser.getText());
-                        parser.next();
-                    }
-                } else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACE_PRINCIPAL.equals(name)) {
-                    AccessControlPrincipalDataImpl principal = null;
-                    while (!(eventType == XmlPullParser.END_TAG && TAG_ACE_PRINCIPAL.equals(name))) {
-                        switch (eventType) {
-                        case XmlPullParser.START_TAG:
-                            if (Constants.NAMESPACE_CMIS.equals(namespace)
-                                    && TAG_ACE_PRINCIPAL_ID.equals(name)) {
-                                parser.next();
-                                principal = new AccessControlPrincipalDataImpl();
-                                principal.setPrincipalId(parser.getText());
-                            }
-                            break;
-                        }
-                        eventType = parser.next();
-                        name = parser.getName();
-                        namespace = parser.getNamespace();
-                    }
-                    // convertExtension(jsonPrincipal, principal,
-                    // PRINCIPAL_KEYS);
-                    ace.setPrincipal(principal);
-                } else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACE_DIRECT.equals(name)) {
-                    parser.next();
-                    Boolean isDirect = Boolean.parseBoolean(parser.getText());
-                    ace.setDirect(isDirect != null ? isDirect.booleanValue() : true);
-                }
-                break;
-            case XmlPullParser.END_TAG:
-                if (Constants.NAMESPACE_CMIS.equals(namespace)
-                        && TAG_ACLCAP_PERMISSION_PERMISSION.equals(name)) {
-                    isPermissionRootTag = false;
-                    ace.setPermissions(permissions);
-                    aces.add(ace);
-                }
-                break;
-            }
-            eventType = parser.next();
-            name = parser.getName();
-            namespace = parser.getNamespace();
-        }
-
-        AccessControlListImpl result = new AccessControlListImpl();
-        result.setAces(aces);
-        // result.setExact(isExact);
+	public AtomPubParser(InputStream stream) {
+		if (stream == null) {
+			throw new IllegalArgumentException("No stream.");
+		}
+
+		this.stream = stream;
+	}
+
+	/**
+	 * Parses the stream.
+	 */
+	public void parse() throws Exception {
+		XmlPullParser parser = Xml.newPullParser();
+		parser.setInput(stream, null);
+
+		try {
+			while (true) {
+				int event = parser.getEventType();
+				if (event == XmlPullParser.START_TAG) {
+					QName name = new QName(parser.getNamespace(), parser.getName());
+
+					if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+						if (TAG_FEED.equals(name.getLocalPart())) {
+							parseResult = parseFeed(parser);
+							break;
+						} else if (TAG_ENTRY.equals(name.getLocalPart())) {
+							parseResult = parseEntry(parser);
+							break;
+						}
+					} else if (Constants.NAMESPACE_CMIS.equals(name.getNamespaceURI())) {
+						if (TAG_ALLOWABLEACTIONS.equals(name.getLocalPart())) {
+							parseResult = new AtomAllowableActions(parseAllowableActions(parser));
+							break;
+						} else if (TAG_ACL.equals(name.getLocalPart())) {
+							parseResult = new AtomAcl(parseACL(parser));
+							break;
+						}
+					} else if (Constants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
+						if (TAG_SERVICE.equals(name.getLocalPart())) {
+							parseResult = parseServiceDoc(parser);
+							break;
+						}
+					}
+				}
+
+				if (!next(parser)) {
+					break;
+				}
+			}
+
+		} finally {
+			// make sure the stream is read and closed in all cases
+			try {
+				byte[] buffer = new byte[4096];
+				while (stream.read(buffer) > -1) {
+				}
+			} catch (Exception e) {
+			}
+
+			try {
+				stream.close();
+			} catch (Exception e) {
+			}
+		}
+	}
+
+	/**
+	 * Return the parse results.
+	 */
+	public AtomBase getResults() {
+		return parseResult;
+	}
+
+	/**
+	 * Parses a service document.
+	 */
+	private static ServiceDoc parseServiceDoc(XmlPullParser parser) throws Exception {
+		ServiceDoc result = new ServiceDoc();
+
+		next(parser);
+
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				QName name = new QName(parser.getNamespace(), parser.getName());
+
+				if (Constants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
+					if (TAG_WORKSPACE.equals(name.getLocalPart())) {
+						result.addWorkspace(parseWorkspace(parser));
+					} else {
+						skip(parser);
+					}
+				} else {
+					skip(parser);
+				}
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	 * Parses a workspace element in a service document.
+	 */
+	private static RepositoryWorkspace parseWorkspace(XmlPullParser parser) throws Exception {
+		RepositoryWorkspace workspace = new RepositoryWorkspace();
+
+		next(parser);
+
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				AtomElement element = parseWorkspaceElement(parser);
+
+				// check if we can extract the workspace id
+				if ((element != null) && (element.getObject() instanceof RepositoryInfo)) {
+					workspace.setId(((RepositoryInfo) element.getObject()).getId());
+				}
+
+				// add to workspace
+				workspace.addElement(element);
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+
+		return workspace;
+	}
+
+	/**
+	 * Parses an Atom feed.
+	 */
+	private AtomFeed parseFeed(XmlPullParser parser) throws Exception {
+		AtomFeed result = new AtomFeed();
+
+		next(parser);
+
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				QName name = new QName(parser.getNamespace(), parser.getName());
+
+				if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+					if (TAG_LINK.equals(name.getLocalPart())) {
+						result.addElement(parseLink(parser));
+					} else if (TAG_ENTRY.equals(name.getLocalPart())) {
+						result.addEntry(parseEntry(parser));
+					} else {
+						skip(parser);
+					}
+				} else if (Constants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
+					if (TAG_NUM_ITEMS.equals(name.getLocalPart())) {
+						result.addElement(parseBigInteger(parser));
+					} else {
+						skip(parser);
+					}
+				} else {
+					skip(parser);
+				}
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+
+		return result;
+	}
+
+	/**
+	 * Parses an Atom entry.
+	 */
+	private AtomEntry parseEntry(XmlPullParser parser) throws Exception {
+		AtomEntry result = new AtomEntry();
+
+		next(parser);
+
+		// walk through all tags in entry
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				AtomElement element = parseElement(parser);
+				if (element != null) {
+					// add to entry
+					result.addElement(element);
+
+					// find and set object id
+					if (element.getObject() instanceof ObjectData) {
+						result.setId(((ObjectData) element.getObject()).getId());
+					} else if (element.getObject() instanceof TypeDefinition) {
+						result.setId(((TypeDefinition) element.getObject()).getId());
+					}
+				}
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+
+		return result;
+	}
+
+	/**
+	 * Parses an element.
+	 */
+	private AtomElement parseElement(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+
+		if (Constants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
+			if (TAG_OBJECT.equals(name.getLocalPart())) {
+				return new AtomElement(name, parseObject(parser));
+			} else if (TAG_PATH_SEGMENT.equals(name.getLocalPart()) || TAG_RELATIVE_PATH_SEGMENT.equals(name.getLocalPart())) {
+				return parseText(parser);
+			} else if (TAG_TYPE.equals(name.getLocalPart())) {
+				// workaround for old Chemistry code - ignore the type namespace
+				String typeAttr = parser.getAttributeValue(Constants.NAMESPACE_XSI, "type");
+				if (typeAttr == null) {
+					return new AtomElement(name, parseTypeDefinition(parser, null));
+				} else if (typeAttr.endsWith(ATTR_DOCUMENT_TYPE)) {
+					return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_DOCUMENT));
+				} else if (typeAttr.endsWith(ATTR_FOLDER_TYPE)) {
+					return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_FOLDER));
+				} else if (typeAttr.endsWith(ATTR_RELATIONSHIP_TYPE)) {
+					return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_RELATIONSHIP));
+				} else if (typeAttr.endsWith(ATTR_POLICY_TYPE)) {
+					return new AtomElement(name, parseTypeDefinition(parser, BaseTypeId.CMIS_POLICY));
+				}
+				throw new CmisRuntimeException("Cannot read type definition!");
+			} else if (TAG_CHILDREN.equals(name.getLocalPart())) {
+				return parseChildren(parser);
+			}
+		} else if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+			if (TAG_LINK.equals(name.getLocalPart())) {
+				return parseLink(parser);
+			} else if (TAG_CONTENT.equals(name.getLocalPart())) {
+				return parseAtomContentSrc(parser);
+			}
+		}
+
+		// we don't know it - skip it
+		skip(parser);
+
+		return null;
+	}
+
+	/**
+	 * Parses a children element.
+	 */
+	private AtomElement parseChildren(XmlPullParser parser) throws Exception {
+		AtomElement result = null;
+		QName childName = new QName(parser.getNamespace(), parser.getName());
+
+		next(parser);
+
+		// walk through the children tag
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				QName name = new QName(parser.getNamespace(), parser.getName());
+
+				if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+					if (TAG_FEED.equals(name.getLocalPart())) {
+						result = new AtomElement(childName, parseFeed(parser));
+					} else {
+						skip(parser);
+					}
+				} else {
+					skip(parser);
+				}
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+
+		return result;
+	}
+
+	/**
+	 * Parses a workspace element.
+	 */
+	private static AtomElement parseWorkspaceElement(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+
+		if (Constants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
+			if (TAG_REPOSITORY_INFO.equals(name.getLocalPart())) {
+				return new AtomElement(name, parseRepositoryInfo(parser));
+			} else if (TAG_URI_TEMPLATE.equals(name.getLocalPart())) {
+				return parseTemplate(parser);
+			}
+		} else if (Constants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+			if (TAG_LINK.equals(name.getLocalPart())) {
+				return parseLink(parser);
+			}
+		} else if (Constants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
+			if (TAG_COLLECTION.equals(name.getLocalPart())) {
+				return parseCollection(parser);
+			}
+		}
+
+		// we don't know it - skip it
+		skip(parser);
+
+		return null;
+	}
+
+	/**
+	 * Parses a collection tag.
+	 */
+	private static AtomElement parseCollection(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+		Map<String, String> result = new HashMap<String, String>();
+
+		result.put("href", parser.getAttributeValue(null, "href"));
+
+		next(parser);
+
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				QName tagName = new QName(parser.getNamespace(), parser.getName());
+				if (Constants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI()) && TAG_COLLECTION_TYPE.equals(tagName.getLocalPart())) {
+					result.put("collectionType", readText(parser));
+				} else {
+					skip(parser);
+				}
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+
+		return new AtomElement(name, result);
+	}
+
+	/**
+	 * Parses a template tag.
+	 */
+	private static AtomElement parseTemplate(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+		Map<String, String> result = new HashMap<String, String>();
+
+		next(parser);
+
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				QName tagName = new QName(parser.getNamespace(), parser.getName());
+				if (Constants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI())) {
+					if (TAG_TEMPLATE_TEMPLATE.equals(tagName.getLocalPart())) {
+						result.put("template", readText(parser));
+					} else if (TAG_TEMPLATE_TYPE.equals(tagName.getLocalPart())) {
+						result.put("type", readText(parser));
+					} else {
+						skip(parser);
+					}
+				} else {
+					skip(parser);
+				}
+			} else if (event == XmlPullParser.END_TAG) {
+				break;
+			} else {
+				if (!next(parser)) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+
+		return new AtomElement(name, result);
+	}
+
+	/**
+	 * Parses a link tag.
+	 */
+	private static AtomElement parseLink(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+		AtomLink result = new AtomLink();
+
+		// save attributes
+		for (int i = 0; i < parser.getAttributeCount(); i++) {
+			if (LINK_REL.equals(parser.getAttributeName(i))) {
+				result.setRel(parser.getAttributeValue(i));
+			} else if (LINK_HREF.equals(parser.getAttributeName(i))) {
+				result.setHref(parser.getAttributeValue(i));
+			} else if (LINK_TYPE.equals(parser.getAttributeName(i))) {
+				result.setType(parser.getAttributeValue(i));
+			}
+		}
+
+		// skip enclosed tags, if any
+		skip(parser);
+
+		return new AtomElement(name, result);
+	}
+
+	/**
+	 * Parses a link tag.
+	 */
+	private static AtomElement parseAtomContentSrc(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+		AtomLink result = new AtomLink();
+		result.setRel(LINK_REL_CONTENT);
+
+		// save attributes
+		for (int i = 0; i < parser.getAttributeCount(); i++) {
+			if (CONTENT_SRC.equals(parser.getAttributeName(i))) {
+				result.setHref(parser.getAttributeValue(i));
+			}
+		}
+
+		// skip enclosed tags, if any
+		skip(parser);
+
+		return new AtomElement(name, result);
+	}
+
+	/**
+	 * Parses a text tag.
+	 */
+	private static AtomElement parseText(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+		return new AtomElement(name, readText(parser));
+	}
+
+	/**
+	 * Parses a text tag and convert it into an integer.
+	 */
+	private static AtomElement parseBigInteger(XmlPullParser parser) throws Exception {
+		QName name = new QName(parser.getNamespace(), parser.getName());
+		return new AtomElement(name, new BigInteger(readText(parser)));
+	}
+
+	/**
+	 * Parses a tag that contains text.
+	 */
+	private static String readText(XmlPullParser parser) throws Exception {
+		StringBuilder sb = new StringBuilder();
+
+		next(parser);
+
+		while (true) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.END_TAG) {
+				break;
+			} else if (event == XmlPullParser.TEXT) {
+				String s = parser.getText();
+				if (s != null) {
+					sb.append(s);
+				}
+			} else if (event == XmlPullParser.START_TAG) {
+				throw new RuntimeException("Unexpected tag: " + parser.getName());
+			}
+
+			if (!next(parser)) {
+				break;
+			}
+		}
+
+		next(parser);
+
+		return sb.toString();
+	}
+
+	/**
+	 * Skips a tag or subtree.
+	 */
+	private static void skip(XmlPullParser parser) throws Exception {
+		int level = 1;
+		while (next(parser)) {
+			int event = parser.getEventType();
+			if (event == XmlPullParser.START_TAG) {
+				level++;
+			} else if (event == XmlPullParser.END_TAG) {
+				level--;
+				if (level == 0) {
+					break;
+				}
+			}
+		}
+
+		next(parser);
+	}
+
+	private static boolean next(XmlPullParser parser) throws Exception {
+		parser.next();
+		return true;
+	}
+
+	// -----------------------------------------------------------------------------------
+	// ------------- NEW ANDROID METHOD
+	// -----------------------------------------------------------------------------------
+
+	private static RepositoryInfo parseRepositoryInfo(XmlPullParser parser) throws Exception {
+		int eventType = parser.next();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+		Map<String, String> repositoryInfoRawValues = new HashMap<String, String>(15);
+		Map<String, String> repositoryCapabilitiesRawValues = new HashMap<String, String>(15);
+		AclCapabilities aclCapabilities = null;
+		List<String> changesOnType = new ArrayList<String>();
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+		while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_REPOSITORY_INFO.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				
+				if (!CmisAtomPubConstants.REPINFO_KEYS.contains(name)){
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					continue;
+				}
+
+				if (TAG_REPINFO_CAPABILITIES.equals(name)) {
+					eventType = parser.next();
+					name = parser.getName();
+					while (!(eventType == XmlPullParser.END_TAG && TAG_REPINFO_CAPABILITIES.equals(name))) {
+						switch (eventType) {
+						case XmlPullParser.START_TAG:
+							parser.next();
+							repositoryCapabilitiesRawValues.put(name, parser.getText());
+							break;
+						}
+						eventType = parser.next();
+						name = parser.getName();
+					}
+				} else if (TAG_REPINFO_ACL_CAPABILITY.equals(name)) {
+					aclCapabilities = parseAclCapabilities(parser);
+				} else if (TAG_REPINFO_CHANGES_ON_TYPE.equals(name)) {
+					parser.next();
+					changesOnType.add(parser.getText());
+				} else if (Constants.NAMESPACE_CMIS.equals(namespace)) {
+					parser.next();
+					repositoryInfoRawValues.put(name, parser.getText());
+				}
+
+				break;
+
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		parser.next();
+		return AtomPubConverter.convertRepositoryInfo(repositoryInfoRawValues, repositoryCapabilitiesRawValues, aclCapabilities, changesOnType, extensions);
+	}
+
+	private static TypeDefinition parseTypeDefinition(XmlPullParser parser, BaseTypeId type) throws Exception {
+		Map<String, String> definitionRawValues = new HashMap<String, String>(15);
+		List<PropertyDefinition<?>> propertyDefinitionList = new ArrayList<PropertyDefinition<?>>(10);
+
+		int eventType = parser.getEventType();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+
+		while (!(eventType == XmlPullParser.END_TAG && TAG_TEMPLATE_TYPE.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				if (name.startsWith(TAG_PROPERTY)) {
+					propertyDefinitionList.add(parsePropertyDefinition(parser));
+				} else if (Constants.NAMESPACE_CMIS.equals(namespace)) {
+					parser.next();
+					definitionRawValues.put(name, parser.getText());
+				} else {
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					continue;
+				}
+
+				break;
+
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		parser.next();
+		return AtomPubConverter.convertTypeDefinition(type, definitionRawValues, propertyDefinitionList, extensions);
+	}
+
+	private static PropertyDefinition<?> parsePropertyDefinition(XmlPullParser parser) throws Exception {
+		String id = null;
+		Map<String, String> propertyTypeRawValues = new HashMap<String, String>(15);
+		id = parser.getName();
+		int eventType = parser.next();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+
+		while (!(eventType == XmlPullParser.END_TAG && id.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				if (Constants.NAMESPACE_CMIS.equals(namespace)) {
+					parser.next();
+					propertyTypeRawValues.put(name, parser.getText());
+				} else {
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					continue;
+				}
+				break;
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		return AtomPubConverter.convertPropertyDefinition(id, propertyTypeRawValues, extensions);
+	}
+
+	private static ObjectData parseObject(XmlPullParser parser) throws Exception {
+		List<RenditionData> renditions = new ArrayList<RenditionData>(3);
+		Properties properties = null;
+		AllowableActions allowableActions = null;
+		Acl acl = null;
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>(2);
+
+		int eventType = parser.next();
+		String name = parser.getName();
+
+		while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_OBJECT.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				
+				if (!CmisAtomPubConstants.OBJECT_KEYS.contains(name)){
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					continue;
+				}
+				
+				if (TAG_OBJECT_PROPERTIES.equals(name)) {
+					properties = parseProperties(parser);
+				} else if (TAG_OBJECT_ALLOWABLE_ACTIONS.equals(name)) {
+					allowableActions = parseAllowableActions(parser);
+				} else if (TAG_OBJECT_ACL.equals(name)) {
+					acl = parseACL(parser);
+				} else if (TAG_OBJECT_RENDITIONS.equals(name)) {
+					renditions.add(parseRenditions(parser));
+				} else {
+					skip(parser);
+				}
+				break;
+
+			}
+			eventType = parser.next();
+			name = parser.getName();
+		}
+
+		// Important !
+		parser.next();
+
+		return AtomPubConverter.convertObject(properties, allowableActions, acl, renditions, extensions);
+	}
+
+	/**
+	 * Converts properties.
+	 * 
+	 * @throws IOException
+	 * @throws XmlPullParserException
+	 */
+	private static Properties parseProperties(XmlPullParser parser) throws Exception {
+		if (parser == null) {
+			return null;
+		}
+
+		int eventType = parser.next();
+		String name = parser.getName();
+		String nameSpace = parser.getNamespace();
+		int countParam = 0;
+		String id = null, displayName = null, queryName = null, localName = null, paramName = null, tag = null;
+		List<String> values = null;
+		List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+		while (!(eventType == XmlPullParser.END_TAG && TAG_OBJECT_PROPERTIES.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+
+				// Extension
+				if (!Constants.NAMESPACE_CMIS.equals(nameSpace)) {
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					nameSpace = parser.getNamespace();
+					continue;
+				}
+
+				tag = name;
+
+				// attributes
+				countParam = parser.getAttributeCount();
+				displayName = null;
+				queryName = null;
+				localName = null;
+				paramName = null;
+				for (int i = 0; i < countParam; i++) {
+					paramName = parser.getAttributeName(i);
+					if (ATTR_PROPERTY_DISPLAYNAME.equals(paramName)) {
+						displayName = parser.getAttributeValue(i);
+					} else if (ATTR_PROPERTY_QUERYNAME.equals(paramName)) {
+						queryName = parser.getAttributeValue(i);
+					} else if (ATTR_PROPERTY_LOCALNAME.equals(paramName)) {
+						localName = parser.getAttributeValue(i);
+					} else if (ATTR_PROPERTY_DEFINITION_ID.equals(paramName)) {
+						id = parser.getAttributeValue(i);
+					}
+				}
+
+				// Values
+				values = new ArrayList<String>(2);
+				while (!(eventType == XmlPullParser.END_TAG && tag.equals(name))) {
+					switch (eventType) {
+					case XmlPullParser.START_TAG:
+						if (ATTR_PROPERTY_VALUE.equals(name)) {
+							parser.next();
+							values.add(parser.getText());
+						}
+						break;
+					}
+					eventType = parser.next();
+					name = parser.getName();
+				}
+
+				// Convert
+				properties.add(AtomPubConverter.convertProperty(tag, id, displayName, queryName, localName, values));
+				break;
+
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			nameSpace = parser.getNamespace();
+		}
+		return AtomPubConverter.convertProperties(properties, extensions);
+	}
+
+	private static Map<String, String> getAttributes(XmlPullParser parser) {
+		Map<String, String> attributes = null;
+		int attributeCount = parser.getAttributeCount();
+		if (parser.getAttributeCount() > 0) {
+			attributes = new HashMap<String, String>(attributeCount);
+			for (int i = 0; i < attributeCount; i++) {
+				attributes.put(parser.getAttributeName(i), parser.getAttributeValue(i));
+			}
+		}
+		return attributes;
+	}
+
+	private static List<CmisExtensionElement> parseExtensions(XmlPullParser parser) throws Exception {
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+		Stack<String> names = new Stack<String>();
+		Stack<String> namespaces = new Stack<String>();
+		Stack<Map<String, String>> attributes = new Stack<Map<String, String>>();
+		Stack<List<CmisExtensionElement>> childrenStack = new Stack<List<CmisExtensionElement>>();
+
+		String name = parser.getName();
+		String id = parser.getName();
+		int eventType = parser.getEventType();
+
+		while (!(eventType == XmlPullParser.END_TAG && id.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+
+				// parse tag info
+				names.push(parser.getName());
+				namespaces.push(parser.getNamespace());
+				attributes.push(getAttributes(parser));
+
+				int beforeEventType = parser.getEventType();
+				eventType = parser.next();
+				switch (eventType) {
+				case XmlPullParser.START_TAG:
+					childrenStack.add(new ArrayList<CmisExtensionElement>());
+					break;
+				case XmlPullParser.TEXT:
+					String value = parser.getText();
+					if ("\n".equals(value)) {
+						if (beforeEventType == XmlPullParser.START_TAG) {
+							childrenStack.add(new ArrayList<CmisExtensionElement>());
+						} else if (eventType == XmlPullParser.END_TAG) {
+							childrenStack.get(childrenStack.size() - 1).add(new CmisExtensionElementImpl(namespaces.pop(), names.pop(), attributes.pop(), (String) null));
+						}
+						parser.next();
+					} else {
+						if (childrenStack.size() != 0) {
+							childrenStack.get(childrenStack.size() - 1).add(new CmisExtensionElementImpl(namespaces.pop(), names.pop(), attributes.pop(), value));
+							parser.next();
+						} else if (id.equals(parser.getName())){
+							extensions.add(new CmisExtensionElementImpl(namespaces.pop(), names.pop(), attributes.pop(), value));
+							return extensions;
+						}
+					}
+
+					break;
+				case XmlPullParser.END_TAG:
+					// case empty tag leaf
+					if (childrenStack.size() != 0) {
+						childrenStack.get(childrenStack.size() - 1).add(new CmisExtensionElementImpl(namespaces.pop(), names.pop(), attributes.pop(), (String) null));
+					} else if (id.equals(parser.getName())){
+						extensions.add(new CmisExtensionElementImpl(namespaces.pop(), names.pop(), attributes.pop(), (String) null));
+						return extensions;
+					}
+					break;
+				}
+				break;
+			case XmlPullParser.END_TAG:
+				eventType = parser.next();
+				if (XmlPullParser.TEXT == eventType) {
+					eventType = parser.next();
+				}
+
+				if (XmlPullParser.END_TAG == eventType) {
+					CmisExtensionElementImpl ext = new CmisExtensionElementImpl(namespaces.pop(), names.pop(), attributes.pop(), childrenStack.pop());
+					if (childrenStack.size() == 0) {
+						extensions.add(ext);
+					} else {
+						childrenStack.get(childrenStack.size() - 1).add(ext);
+					}
+				}
+				break;
+			}
+
+			eventType = parser.getEventType();
+			name = parser.getName();
+		}
+
+		if (extensions.isEmpty() && childrenStack.size() == 1) {
+			extensions.addAll(childrenStack.pop());
+		}
+
+		return extensions;
+	}
+
+	private static RenditionData parseRenditions(XmlPullParser parser) throws Exception {
+		Map<String, String> rendition = new HashMap<String, String>(15);
+		int eventType = parser.next();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+		while (!(eventType == XmlPullParser.END_TAG && TAG_RENDITION.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				if (Constants.NAMESPACE_CMIS.equals(namespace)) {
+					parser.next();
+					rendition.put(name, parser.getText());
+				} else {
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					namespace = parser.getNamespace();
+					continue;
+				}
+				break;
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		return AtomPubConverter.convertRendition(rendition, extensions);
+	}
+
+	private static AllowableActions parseAllowableActions(XmlPullParser parser) throws Exception {
+		Map<String, String> allowableActionsRawValues = new HashMap<String, String>(15);
+		int eventType = parser.next();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+		List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+		while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_ALLOWABLEACTIONS.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				if (Constants.NAMESPACE_CMIS.equals(namespace)) {
+					parser.next();
+					allowableActionsRawValues.put(name, parser.getText());
+				} else {
+					extensions.addAll(parseExtensions(parser));
+					eventType = parser.next();
+					if (XmlPullParser.TEXT == eventType) {
+						eventType = parser.next();
+					}
+					name = parser.getName();
+					namespace = parser.getNamespace();
+					continue;
+				}
+				break;
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		return AtomPubConverter.convertAllowableActions(allowableActionsRawValues, extensions);
+	}
+
+	private static AclCapabilities parseAclCapabilities(XmlPullParser parser) throws Exception {
+		Map<String, String> AclCapabilitiesRawValues = new HashMap<String, String>(15);
+		List<PermissionDefinition> permissionDefinitionList = new ArrayList<PermissionDefinition>();
+		Map<String, PermissionMapping> permMap = new HashMap<String, PermissionMapping>();
+
+		int eventType = parser.next();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+
+		while (!(eventType == XmlPullParser.END_TAG && TAG_REPINFO_ACL_CAPABILITY.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_PERMISSIONS.equals(name)) {
+
+					String permission = null, description = null;
+					// Permissions
+					while (!(eventType == XmlPullParser.END_TAG && TAG_ACLCAP_PERMISSIONS.equals(name))) {
+						switch (eventType) {
+						case XmlPullParser.START_TAG:
+							if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_PERMISSION_PERMISSION.equals(name)) {
+								parser.next();
+								permission = parser.getText();
+							} else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_PERMISSION_DESCRIPTION.equals(name)) {
+								parser.next();
+								description = parser.getText();
+							}
+							break;
+						}
+						eventType = parser.next();
+						name = parser.getName();
+					}
+					PermissionDefinitionDataImpl permDef = new PermissionDefinitionDataImpl();
+					permDef.setPermission(permission);
+					permDef.setDescription(description);
+
+					// convertExtension(permissionMap, permDef,
+					// ACLCAP_PERMISSION_KEYS);
+
+					permissionDefinitionList.add(permDef);
+
+				} else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_MAPPING.equals(name)) {
+
+					String key = null;
+					List<String> permList = new ArrayList<String>();
+					// MAPPINGS
+					while (!(eventType == XmlPullParser.END_TAG && TAG_ACLCAP_MAPPING.equals(name))) {
+						switch (eventType) {
+						case XmlPullParser.START_TAG:
+							if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_MAPPING_KEY.equals(name)) {
+								parser.next();
+								key = parser.getText();
+							} else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_MAPPING_PERMISSION.equals(name)) {
+								parser.next();
+								permList.add(parser.getText());
+							}
+							break;
+						}
+						eventType = parser.next();
+						name = parser.getName();
+					}
+					PermissionMappingDataImpl mapping = new PermissionMappingDataImpl();
+					mapping.setKey(key);
+					mapping.setPermissions(permList);
+
+					// convertExtension(permissionMap, mapping,
+					// ACLCAP_MAPPING_KEYS);
+
+					permMap.put(key, mapping);
+
+				} else if (Constants.NAMESPACE_CMIS.equals(namespace)) {
+					parser.next();
+					AclCapabilitiesRawValues.put(name, parser.getText());
+				}
+				break;
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		return AtomPubConverter.convertAclCapabilities(AclCapabilitiesRawValues, permissionDefinitionList, permMap);
+	}
+
+	private static Acl parseACL(XmlPullParser parser) throws Exception {
+		int eventType = parser.next();
+		String name = parser.getName();
+		String namespace = parser.getNamespace();
+		boolean isPermissionRootTag = false;
+		List<Ace> aces = new ArrayList<Ace>();
+		List<String> permissions = null;
+		AccessControlEntryImpl ace = null;
+
+		while (!(eventType == XmlPullParser.END_TAG && Constants.SELECTOR_ACL.equals(name))) {
+			switch (eventType) {
+			case XmlPullParser.START_TAG:
+				if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_PERMISSION_PERMISSION.equals(name)) {
+					if (isPermissionRootTag == false) {
+						isPermissionRootTag = true;
+						permissions = new ArrayList<String>();
+						ace = new AccessControlEntryImpl();
+					} else {
+						parser.next();
+						permissions.add(parser.getText());
+						parser.next();
+					}
+				} else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACE_PRINCIPAL.equals(name)) {
+					AccessControlPrincipalDataImpl principal = null;
+					while (!(eventType == XmlPullParser.END_TAG && TAG_ACE_PRINCIPAL.equals(name))) {
+						switch (eventType) {
+						case XmlPullParser.START_TAG:
+							if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACE_PRINCIPAL_ID.equals(name)) {
+								parser.next();
+								principal = new AccessControlPrincipalDataImpl();
+								principal.setPrincipalId(parser.getText());
+							}
+							break;
+						}
+						eventType = parser.next();
+						name = parser.getName();
+						namespace = parser.getNamespace();
+					}
+					// convertExtension(jsonPrincipal, principal,
+					// PRINCIPAL_KEYS);
+					ace.setPrincipal(principal);
+				} else if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACE_DIRECT.equals(name)) {
+					parser.next();
+					Boolean isDirect = Boolean.parseBoolean(parser.getText());
+					ace.setDirect(isDirect != null ? isDirect.booleanValue() : true);
+				}
+				break;
+			case XmlPullParser.END_TAG:
+				if (Constants.NAMESPACE_CMIS.equals(namespace) && TAG_ACLCAP_PERMISSION_PERMISSION.equals(name)) {
+					isPermissionRootTag = false;
+					ace.setPermissions(permissions);
+					aces.add(ace);
+				}
+				break;
+			}
+			eventType = parser.next();
+			name = parser.getName();
+			namespace = parser.getNamespace();
+		}
+
+		AccessControlListImpl result = new AccessControlListImpl();
+		result.setAces(aces);
+		// result.setExact(isExact);
 
-        // convertExtension(json, result, ACL_KEYS);
+		// convertExtension(json, result, ACL_KEYS);
 
-        return result;
-    }
+		return result;
+	}
 
 }

Modified: chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java?rev=1297943&r1=1297942&r2=1297943&view=diff
==============================================================================
--- chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java (original)
+++ chemistry/opencmis/branches/android/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/CmisAtomPubConstants.java Wed Mar  7 11:27:16 2012
@@ -18,6 +18,9 @@
  */
 package org.apache.chemistry.opencmis.client.bindings.spi.atompub;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Constants for AtomPub.
  */
@@ -95,16 +98,39 @@ public final class CmisAtomPubConstants 
     public static final String TAG_REPINFO_REPOSITORY_URL = "repositoryUrl";
     public static final String TAG_REPINFO_ROOT_FOLDER_URL = "rootFolderUrl";
     public static final String TAG_REPINFO_CAPABILITIES = "capabilities";
-    public static final String TAG_REPINFO_ACL_CAPABILITIES = "aclCapabilities";
+    public static final String TAG_REPINFO_ACL_CAPABILITY = "aclCapability";
     public static final String TAG_REPINFO_CHANGE_LOCK_TOKEN = "latestChangeLogToken";
     public static final String TAG_REPINFO_CMIS_VERSION_SUPPORTED = "cmisVersionSupported";
     public static final String TAG_REPINFO_THIN_CLIENT_URI = "thinClientURI";
     public static final String TAG_REPINFO_CHANGES_INCOMPLETE = "changesIncomplete";
     public static final String TAG_REPINFO_CHANGES_ON_TYPE = "changesOnType";
-    public static final String TAG_REPINFO_PRINCIPAL_ID_ANONYMOUS = "principalIdAnonymous";
-    public static final String TAG_REPINFO_PRINCIPAL_ID_ANYONE = "principalIdAnyone";
+    public static final String TAG_REPINFO_PRINCIPAL_ANONYMOUS = "principalAnonymous";
+    public static final String TAG_REPINFO_PRINCIPAL_ANYONE = "principalAnyone";
+    
+    
+    public static final Set<String> REPINFO_KEYS = new HashSet<String>();
+    static {
+        REPINFO_KEYS.add(TAG_REPINFO_ID);
+        REPINFO_KEYS.add(TAG_REPINFO_NAME);
+        REPINFO_KEYS.add(TAG_REPINFO_DESCRIPTION);
+        REPINFO_KEYS.add(TAG_REPINFO_VENDOR);
+        REPINFO_KEYS.add(TAG_REPINFO_PRODUCT);
+        REPINFO_KEYS.add(TAG_REPINFO_PRODUCT_VERSION);
+        REPINFO_KEYS.add(TAG_REPINFO_ROOT_FOLDER_ID);
+        REPINFO_KEYS.add(TAG_REPINFO_REPOSITORY_URL);
+        REPINFO_KEYS.add(TAG_REPINFO_ROOT_FOLDER_URL);
+        REPINFO_KEYS.add(TAG_REPINFO_CAPABILITIES);
+        REPINFO_KEYS.add(TAG_REPINFO_ACL_CAPABILITY);
+        REPINFO_KEYS.add(TAG_REPINFO_CHANGE_LOCK_TOKEN);
+        REPINFO_KEYS.add(TAG_REPINFO_CMIS_VERSION_SUPPORTED);
+        REPINFO_KEYS.add(TAG_REPINFO_THIN_CLIENT_URI);
+        REPINFO_KEYS.add(TAG_REPINFO_CHANGES_INCOMPLETE);
+        REPINFO_KEYS.add(TAG_REPINFO_CHANGES_ON_TYPE);
+        REPINFO_KEYS.add(TAG_REPINFO_PRINCIPAL_ANONYMOUS);
+        REPINFO_KEYS.add(TAG_REPINFO_PRINCIPAL_ANYONE);
+    }
+    
     
-    public static final String TAG_ACLCAP_ACL = "aclCapability";
     public static final String TAG_ACLCAP_ACL_PROPAGATION = "propagation";
     public static final String TAG_ACLCAP_SUPPORTED_PERMISSIONS = "supportedPermissions";
     public static final String TAG_ACLCAP_PERMISSIONS = "permissions";
@@ -194,4 +220,26 @@ public final class CmisAtomPubConstants 
     public static final String TAG_QUERY_STATEMENT = "statement";
 
     
+    public static final String TAG_OBJECT_PROPERTIES = "properties";
+    public static final String TAG_OBJECT_ALLOWABLE_ACTIONS = "allowableActions";
+    public static final String TAG_OBJECT_RELATIONSHIPS = "relationships";
+    public static final String TAG_OBJECT_CHANGE_EVENT_INFO = "changeEventInfo";
+    public static final String TAG_OBJECT_ACL = "acl";
+    public static final String TAG_OBJECT_EXACT_ACL = "exactACL";
+    public static final String TAG_OBJECT_POLICY_IDS = "policyIds";
+    public static final String TAG_OBJECT_RENDITIONS = "renditions";
+    
+    public static final Set<String> OBJECT_KEYS = new HashSet<String>();
+    static {
+        OBJECT_KEYS.add(TAG_OBJECT_PROPERTIES);
+        OBJECT_KEYS.add(TAG_OBJECT_ALLOWABLE_ACTIONS);
+        OBJECT_KEYS.add(TAG_OBJECT_RELATIONSHIPS);
+        OBJECT_KEYS.add(TAG_OBJECT_CHANGE_EVENT_INFO);
+        OBJECT_KEYS.add(TAG_OBJECT_ACL);
+        OBJECT_KEYS.add(TAG_OBJECT_EXACT_ACL);
+        OBJECT_KEYS.add(TAG_OBJECT_POLICY_IDS);
+        OBJECT_KEYS.add(TAG_OBJECT_RENDITIONS);
+    }
+    
+    
 }



Mime
View raw message