You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2009/07/15 15:48:03 UTC
svn commit: r794271 - in /incubator/chemistry/trunk/chemistry:
chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/
chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/
chemistry-atompub-client/src/tes...
Author: fguillaume
Date: Wed Jul 15 13:48:03 2009
New Revision: 794271
URL: http://svn.apache.org/viewvc?rev=794271&view=rev
Log:
CMIS-23: type feed must use folderType, relationshipType, policyType not just documentType
Added:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java (with props)
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml (with props)
Modified:
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ReadContext.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java?rev=794271&r1=794270&r2=794271&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/TypeEntryReader.java Wed Jul 15 13:48:03 2009
@@ -13,6 +13,8 @@
*
* Authors:
* Bogdan Stefanescu, Nuxeo
+ * Ugo Cei, Sourcesense
+ * Florent Guillaume, Nuxeo
*/
package org.apache.chemistry.atompub.client;
@@ -28,12 +30,16 @@
import org.apache.chemistry.atompub.client.stax.ReadContext;
import org.apache.chemistry.xml.stax.ChildrenNavigator;
import org.apache.chemistry.xml.stax.StaxReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
*
*/
public class TypeEntryReader extends AbstractEntryReader<APPType> {
+ private static final Log log = LogFactory.getLog(TypeEntryReader.class);
+
public static final TypeEntryReader INSTANCE = new TypeEntryReader();
@Override
@@ -56,12 +62,17 @@
@Override
protected void readCmisElement(ReadContext context, StaxReader reader,
APPType entry) throws XMLStreamException {
- if (CMIS.DOCUMENT_TYPE.getLocalPart().equals(reader.getLocalName())) {
+ String localName = reader.getLocalName();
+ if (CMIS.DOCUMENT_TYPE.getLocalPart().equals(localName)
+ || CMIS.FOLDER_TYPE.getLocalPart().equals(localName)
+ || CMIS.RELATIONSHIP_TYPE.getLocalPart().equals(localName)
+ || CMIS.POLICY_TYPE.getLocalPart().equals(localName)) {
ChildrenNavigator children = reader.getChildren();
Map<String, String> map = new HashMap<String, String>();
Map<String, PropertyDefinition> pdefs = null;
while (children.next()) {
- if (reader.getLocalName().startsWith("property")) {
+ String name = reader.getLocalName();
+ if (name.startsWith("property")) {
if (pdefs == null) {
pdefs = new HashMap<String, PropertyDefinition>();
}
@@ -72,11 +83,24 @@
}
pdefs.put(pdef.getName(), pdef);
} else {
+ String text;
try {
- map.put(reader.getLocalName(), reader.getElementText());
- } catch (Exception e) {
- e.printStackTrace();
+ text = reader.getElementText();
+ } catch (XMLStreamException e) {
+ log.error("Cannot read text element for: " + name, e);
+ continue;
+ }
+ if (name.equals(CMIS.BASE_TYPE.getLocalPart())) {
+ // check base type coherent with base element
+ // eg "folder" for a <cmis:folderType>
+ if (!localName.startsWith(text)) {
+ throw new IllegalArgumentException(
+ String.format(
+ "Type element <cmis:%s> cannot have base type: %s",
+ localName, text));
+ }
}
+ map.put(name, text);
}
}
entry.init(map, pdefs);
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ReadContext.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ReadContext.java?rev=794271&r1=794270&r2=794271&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ReadContext.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/stax/ReadContext.java Wed Jul 15 13:48:03 2009
@@ -13,6 +13,7 @@
*
* Authors:
* Bogdan Stefanescu, Nuxeo
+ * Florent Guillaume, Nuxeo
*/
package org.apache.chemistry.atompub.client.stax;
@@ -53,20 +54,12 @@
public ReadContext(Repository repository, Type type) {
this.type = type;
this.repository = repository;
- if (repository == null) {
- throw new IllegalArgumentException(
- "A BuildContext must be bound to a repository");
- }
}
public ReadContext(Connection connection, Type type) {
this.connection = connection;
this.type = type;
this.repository = connection.getRepository();
- if (repository == null) {
- throw new IllegalArgumentException(
- "A BuildContext must be bound to a repository");
- }
}
public Repository getRepository() {
Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java?rev=794271&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java Wed Jul 15 13:48:03 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ * Ugo Cei, Sourcesense
+ * Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.client;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.Type;
+import org.apache.chemistry.atompub.client.stax.ReadContext;
+
+public class TypeFeedReaderTest extends TestCase {
+
+ public void testReadTypesFeed() throws Exception {
+ InputStream is = getClass().getResourceAsStream("/feed-types.xml");
+ Map<String, Type> typeRegistry = TypeFeedReader.INSTANCE.read(
+ new ReadContext((Repository) null), is);
+ assertEquals(5, typeRegistry.size());
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/java/org/apache/chemistry/atompub/client/TypeFeedReaderTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml?rev=794271&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml Wed Jul 15 13:48:03 2009
@@ -0,0 +1,129 @@
+<?xml version='1.0' encoding='utf-8'?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901">
+ <id>urn:x-id:types</id>
+ <title type="text">Types</title>
+ <author>
+ <name>system</name>
+ </author>
+ <updated>2009-07-15T11:20:19.389Z</updated>
+ <entry>
+ <id>urn:x-tid:document</id>
+ <title type="text">Document Type</title>
+ <updated>2009-07-15T11:20:19.421Z</updated>
+ <link href="http://127.0.0.1:8080/cmis/type/document" rel="self" />
+ <link href="http://127.0.0.1:8080/cmis/type/document" rel="edit" />
+ <link href="http://127.0.0.1:8080/cmis/type/document" rel="alternate" />
+ <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
+ <cmis:documentType>
+ <cmis:typeId>document</cmis:typeId>
+ <cmis:queryName>Document</cmis:queryName>
+ <cmis:displayName>Document Type</cmis:displayName>
+ <cmis:baseType>document</cmis:baseType>
+ <cmis:baseTypeQueryName>Document</cmis:baseTypeQueryName>
+ <cmis:parentId />
+ <cmis:description></cmis:description>
+ <cmis:creatable>true</cmis:creatable>
+ <cmis:fileable>true</cmis:fileable>
+ <cmis:queryable>true</cmis:queryable>
+ <cmis:controllable>true</cmis:controllable>
+ <cmis:versionable>true</cmis:versionable>
+ <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
+ </cmis:documentType>
+ </entry>
+ <entry>
+ <id>urn:x-tid:folder</id>
+ <title type="text">Folder Type</title>
+ <updated>2009-07-15T11:20:19.431Z</updated>
+ <link href="http://127.0.0.1:8080/cmis/type/folder" rel="self" />
+ <link href="http://127.0.0.1:8080/cmis/type/folder" rel="edit" />
+ <link href="http://127.0.0.1:8080/cmis/type/folder" rel="alternate" />
+ <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
+ <cmis:folderType>
+ <cmis:typeId>folder</cmis:typeId>
+ <cmis:queryName>Folder</cmis:queryName>
+ <cmis:displayName>Folder Type</cmis:displayName>
+ <cmis:baseType>folder</cmis:baseType>
+ <cmis:baseTypeQueryName>Folder</cmis:baseTypeQueryName>
+ <cmis:parentId />
+ <cmis:description></cmis:description>
+ <cmis:creatable>true</cmis:creatable>
+ <cmis:fileable>true</cmis:fileable>
+ <cmis:queryable>true</cmis:queryable>
+ <cmis:controllable>false</cmis:controllable>
+ <cmis:versionable>false</cmis:versionable>
+ <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
+ </cmis:folderType>
+ </entry>
+ <entry>
+ <id>urn:x-tid:relationship</id>
+ <title type="text">Relationship Type</title>
+ <updated>2009-07-15T11:20:19.437Z</updated>
+ <link href="http://127.0.0.1:8080/cmis/type/relationship" rel="self" />
+ <link href="http://127.0.0.1:8080/cmis/type/relationship" rel="edit" />
+ <link href="http://127.0.0.1:8080/cmis/type/relationship" rel="alternate" />
+ <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
+ <cmis:relationshipType>
+ <cmis:typeId>relationship</cmis:typeId>
+ <cmis:queryName>Relationship</cmis:queryName>
+ <cmis:displayName>Relationship Type</cmis:displayName>
+ <cmis:baseType>relationship</cmis:baseType>
+ <cmis:baseTypeQueryName>Relationship</cmis:baseTypeQueryName>
+ <cmis:parentId />
+ <cmis:description></cmis:description>
+ <cmis:creatable>true</cmis:creatable>
+ <cmis:fileable>false</cmis:fileable>
+ <cmis:queryable>true</cmis:queryable>
+ <cmis:controllable>false</cmis:controllable>
+ <cmis:versionable>false</cmis:versionable>
+ <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
+ </cmis:relationshipType>
+ </entry>
+ <entry>
+ <id>urn:x-tid:policy</id>
+ <title type="text">Policy Type</title>
+ <updated>2009-07-15T11:20:19.403Z</updated>
+ <link href="http://127.0.0.1:8080/cmis/type/policy" rel="self" />
+ <link href="http://127.0.0.1:8080/cmis/type/policy" rel="edit" />
+ <link href="http://127.0.0.1:8080/cmis/type/policy" rel="alternate" />
+ <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
+ <cmis:policyType>
+ <cmis:typeId>policy</cmis:typeId>
+ <cmis:queryName>Policy</cmis:queryName>
+ <cmis:displayName>Policy Type</cmis:displayName>
+ <cmis:baseType>policy</cmis:baseType>
+ <cmis:baseTypeQueryName>Policy</cmis:baseTypeQueryName>
+ <cmis:parentId />
+ <cmis:description></cmis:description>
+ <cmis:creatable>true</cmis:creatable>
+ <cmis:fileable>false</cmis:fileable>
+ <cmis:queryable>true</cmis:queryable>
+ <cmis:controllable>false</cmis:controllable>
+ <cmis:versionable>false</cmis:versionable>
+ <cmis:includedInSupertypeQuery>true</cmis:includedInSupertypeQuery>
+ </cmis:policyType>
+ </entry>
+ <entry>
+ <id>urn:x-tid:Root</id>
+ <title type="text">Root Folder Type</title>
+ <updated>2009-07-15T11:20:19.427Z</updated>
+ <link href="http://127.0.0.1:8080/cmis/type/Root" rel="self" />
+ <link href="http://127.0.0.1:8080/cmis/type/Root" rel="edit" />
+ <link href="http://127.0.0.1:8080/cmis/type/Root" rel="alternate" />
+ <link href="http://127.0.0.1:8080/cmis/repository" rel="repository" />
+ <cmis:folderType>
+ <cmis:typeId>Root</cmis:typeId>
+ <cmis:queryName>Root</cmis:queryName>
+ <cmis:displayName>Root Folder Type</cmis:displayName>
+ <cmis:baseType>folder</cmis:baseType>
+ <cmis:baseTypeQueryName>Folder</cmis:baseTypeQueryName>
+ <cmis:parentId>folder</cmis:parentId>
+ <cmis:description></cmis:description>
+ <cmis:creatable>false</cmis:creatable>
+ <cmis:fileable>false</cmis:fileable>
+ <cmis:queryable>false</cmis:queryable>
+ <cmis:controllable>false</cmis:controllable>
+ <cmis:versionable>false</cmis:versionable>
+ <cmis:includedInSupertypeQuery>false</cmis:includedInSupertypeQuery>
+ </cmis:folderType>
+ </entry>
+</feed>
Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/test/resources/feed-types.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java?rev=794271&r1=794270&r2=794271&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISTypesCollection.java Wed Jul 15 13:48:03 2009
@@ -105,7 +105,24 @@
// CMIS-specific
// TODO refactor this to be a proper ExtensibleElement
- Element dt = factory.newElement(CMIS.DOCUMENT_TYPE, entry);
+ QName typeElementQName;
+ switch (type.getBaseType()) {
+ case DOCUMENT:
+ typeElementQName = CMIS.DOCUMENT_TYPE;
+ break;
+ case FOLDER:
+ typeElementQName = CMIS.FOLDER_TYPE;
+ break;
+ case RELATIONSHIP:
+ typeElementQName = CMIS.RELATIONSHIP_TYPE;
+ break;
+ case POLICY:
+ typeElementQName = CMIS.POLICY_TYPE;
+ break;
+ default:
+ throw new AssertionError(type.getBaseType().toString());
+ }
+ Element dt = factory.newElement(typeElementQName, entry);
Element el;
// note: setText is called in a separate statement as JDK 5 has problems
// compiling when it's on one line (compiler generics bug)
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java?rev=794271&r1=794270&r2=794271&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub/src/main/java/org/apache/chemistry/atompub/CMIS.java Wed Jul 15 13:48:03 2009
@@ -83,6 +83,12 @@
public static final QName DOCUMENT_TYPE = CMISName("documentType");
+ public static final QName FOLDER_TYPE = CMISName("folderType");
+
+ public static final QName RELATIONSHIP_TYPE = CMISName("relationshipType");
+
+ public static final QName POLICY_TYPE = CMISName("policyType");
+
public static final QName TYPE_ID = CMISName("typeId");
public static final QName QUERY_NAME = CMISName("queryName");