chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r980513 [7/15] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/dummy/ chemistry-opencmis-server-bindings/src/main/java/org/apache...
Date Thu, 29 Jul 2010 17:13:30 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java Thu Jul 29 17:13:28 2010
@@ -1,227 +1,227 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory.server;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.data.Acl;
-import org.apache.chemistry.opencmis.commons.data.ContentStream;
-import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
-import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
-import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
-import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
-import org.apache.chemistry.opencmis.commons.server.CallContext;
-import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
-import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.FilterParser;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
-import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class InMemoryVersioningServiceImpl extends InMemoryAbstractServiceImpl {
-
-    private static final Log LOG = LogFactory.getLog(InMemoryVersioningServiceImpl.class.getName());
-
-    InMemoryObjectServiceImpl fObjectService; // real implementation of the
-    // service
-    AtomLinkInfoProvider fAtomLinkProvider;
-
-    public InMemoryVersioningServiceImpl(StoreManager storeManager, InMemoryObjectServiceImpl objectService) {
-        super(storeManager);
-        fObjectService = objectService;
-        fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
-    }
-
-    public void cancelCheckOut(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
-
-        StoredObject so = checkStandardParameters(repositoryId, objectId);
-        String user = context.getUsername();
-        VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
-
-        verDoc.cancelCheckOut(user);
-    }
-
-    public void checkIn(CallContext context, String repositoryId, Holder<String> objectId, Boolean major,
-            Properties properties, ContentStream contentStream, String checkinComment, List<String> policies,
-            Acl addAces, Acl removeAces, ExtensionsData extension, ObjectInfoHandler objectInfos) {
-
-        StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-        String user = context.getUsername();
-        VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
-
-        DocumentVersion pwc = verDoc.getPwc();
-
-        if (null != contentStream)
-            pwc.setContent(contentStream, false);
-
-        if (null != properties && null != properties.getProperties())
-            pwc.setCustomProperties(properties.getProperties());
-
-        verDoc.checkIn(major, checkinComment, user);
-
-        // To be able to provide all Atom links in the response we need
-        // additional information:
-        if (context.isObjectInfoRequired()) {
-            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
-            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
-            objectInfos.addObjectInfo(objectInfo);
-        }
-    }
-
-    public void checkOut(CallContext context, String repositoryId, Holder<String> objectId,
-            ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHandler objectInfos) {
-
-        StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
-        TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
-        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
-            throw new CmisNotSupportedException("Only documents can be checked-out.");
-        else if (!((DocumentTypeDefinition) typeDef).isVersionable())
-            throw new CmisNotSupportedException("Object can't be checked-out, type is not versionable.");
-
-        checkIsVersionableObject(so);
-
-        VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
-
-        ContentStream content = null;
-
-        if (so instanceof DocumentVersion) {
-            // get document the version is contained in to c
-            content = ((DocumentVersion) so).getContent(0, -1);
-        } else {
-            content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
-        }
-
-        if (verDoc.isCheckedOut())
-            throw new CmisUpdateConflictException("Document " + objectId.getValue() + " is already checked out.");
-
-        String user = context.getUsername();
-        checkHasUser(user);
-
-        DocumentVersion pwc = verDoc.checkOut(content, user);
-        objectId.setValue(pwc.getId()); // return the id of the created pwc
-
-        // To be able to provide all Atom links in the response we need
-        // additional information:
-        if (context.isObjectInfoRequired()) {
-            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
-            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, pwc, objectInfo);
-            objectInfos.addObjectInfo(objectInfo);
-        }
-    }
-
-    public List<ObjectData> getAllVersions(CallContext context, String repositoryId, String versionSeriesId,
-            String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHandler objectInfos) {
-
-        if (null == versionSeriesId)
-            throw new RuntimeException("getAllVersions requires a version series id, but ist was null.");
-
-        StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
-
-        if (!(so instanceof VersionedDocument))
-            throw new RuntimeException("Object is not instance of a VersionedDocument (version series)");
-
-        VersionedDocument verDoc = (VersionedDocument) so;
-        List<ObjectData> res = new ArrayList<ObjectData>();
-        List<DocumentVersion> versions = verDoc.getAllVersions();
-        for (DocumentVersion version : versions) {
-            ObjectData objData = getObject(context, repositoryId, version.getId(), filter, includeAllowableActions,
-                    extension, objectInfos);
-            res.add(objData);
-        }
-
-        // provide information for Atom links for version series:
-        if (context.isObjectInfoRequired()) {
-            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
-            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
-            objectInfos.addObjectInfo(objectInfo);
-        }
-
-        return res;
-    }
-
-    public ObjectData getObjectOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
-            Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
-            String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension,
-            ObjectInfoHandler objectInfos) {
-
-        StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
-        ObjectData objData = null;
-
-        if (so instanceof VersionedDocument) {
-            VersionedDocument verDoc = (VersionedDocument) so;
-            DocumentVersion latestVersion = verDoc.getLatestVersion(major);
-            objData = getObject(context, repositoryId, latestVersion.getId(), filter, includeAllowableActions,
-                    extension, objectInfos);
-        } else if (so instanceof Document) {
-            objData = getObject(context, repositoryId, so.getId(), filter, includeAllowableActions, extension,
-                    objectInfos);
-        } else
-            throw new RuntimeException("Object is not instance of a document (version series)");
-
-        // provide information for Atom links for version series:
-        if (context.isObjectInfoRequired()) {
-            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
-            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
-            objectInfos.addObjectInfo(objectInfo);
-        }
-
-        return objData;
-    }
-
-    public Properties getPropertiesOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
-            Boolean major, String filter, ExtensionsData extension) {
-
-        StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
-        StoredObject latestVersionObject = null;
-
-        if (so instanceof VersionedDocument) {
-            VersionedDocument verDoc = (VersionedDocument) so;
-            latestVersionObject = verDoc.getLatestVersion(major);
-        } else if (so instanceof Document) {
-            latestVersionObject = so;
-        } else
-            throw new RuntimeException("Object is not instance of a document (version series)");
-
-        List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-        TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
-        Properties props = PropertyCreationHelper.getPropertiesFromObject(latestVersionObject, td, 
-                requestedIds);
-
-        return props;
-    }
-
-    private ObjectData getObject(CallContext context, String repositoryId, String objectId, String filter,
-            Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHandler objectInfos) {
-
-        return fObjectService.getObject(context, repositoryId, objectId, filter, includeAllowableActions,
-                IncludeRelationships.NONE, null, false, includeAllowableActions, extension, objectInfos);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
+import org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl;
+import org.apache.chemistry.opencmis.commons.server.CallContext;
+import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.chemistry.opencmis.inmemory.FilterParser;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.DocumentVersion;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
+import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class InMemoryVersioningServiceImpl extends InMemoryAbstractServiceImpl {
+
+    private static final Log LOG = LogFactory.getLog(InMemoryVersioningServiceImpl.class.getName());
+
+    InMemoryObjectServiceImpl fObjectService; // real implementation of the
+    // service
+    AtomLinkInfoProvider fAtomLinkProvider;
+
+    public InMemoryVersioningServiceImpl(StoreManager storeManager, InMemoryObjectServiceImpl objectService) {
+        super(storeManager);
+        fObjectService = objectService;
+        fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
+    }
+
+    public void cancelCheckOut(CallContext context, String repositoryId, String objectId, ExtensionsData extension) {
+
+        StoredObject so = checkStandardParameters(repositoryId, objectId);
+        String user = context.getUsername();
+        VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
+
+        verDoc.cancelCheckOut(user);
+    }
+
+    public void checkIn(CallContext context, String repositoryId, Holder<String> objectId, Boolean major,
+            Properties properties, ContentStream contentStream, String checkinComment, List<String> policies,
+            Acl addAces, Acl removeAces, ExtensionsData extension, ObjectInfoHandler objectInfos) {
+
+        StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
+        String user = context.getUsername();
+        VersionedDocument verDoc = testHasProperCheckedOutStatus(so, user);
+
+        DocumentVersion pwc = verDoc.getPwc();
+
+        if (null != contentStream)
+            pwc.setContent(contentStream, false);
+
+        if (null != properties && null != properties.getProperties())
+            pwc.setCustomProperties(properties.getProperties());
+
+        verDoc.checkIn(major, checkinComment, user);
+
+        // To be able to provide all Atom links in the response we need
+        // additional information:
+        if (context.isObjectInfoRequired()) {
+            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
+            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
+            objectInfos.addObjectInfo(objectInfo);
+        }
+    }
+
+    public void checkOut(CallContext context, String repositoryId, Holder<String> objectId,
+            ExtensionsData extension, Holder<Boolean> contentCopied, ObjectInfoHandler objectInfos) {
+
+        StoredObject so = checkStandardParameters(repositoryId, objectId.getValue());
+        TypeDefinition typeDef = getTypeDefinition(repositoryId, so);
+        if (!typeDef.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT))
+            throw new CmisNotSupportedException("Only documents can be checked-out.");
+        else if (!((DocumentTypeDefinition) typeDef).isVersionable())
+            throw new CmisNotSupportedException("Object can't be checked-out, type is not versionable.");
+
+        checkIsVersionableObject(so);
+
+        VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);
+
+        ContentStream content = null;
+
+        if (so instanceof DocumentVersion) {
+            // get document the version is contained in to c
+            content = ((DocumentVersion) so).getContent(0, -1);
+        } else {
+            content = ((VersionedDocument) so).getLatestVersion(false).getContent(0, -1);
+        }
+
+        if (verDoc.isCheckedOut())
+            throw new CmisUpdateConflictException("Document " + objectId.getValue() + " is already checked out.");
+
+        String user = context.getUsername();
+        checkHasUser(user);
+
+        DocumentVersion pwc = verDoc.checkOut(content, user);
+        objectId.setValue(pwc.getId()); // return the id of the created pwc
+
+        // To be able to provide all Atom links in the response we need
+        // additional information:
+        if (context.isObjectInfoRequired()) {
+            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
+            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, pwc, objectInfo);
+            objectInfos.addObjectInfo(objectInfo);
+        }
+    }
+
+    public List<ObjectData> getAllVersions(CallContext context, String repositoryId, String versionSeriesId,
+            String filter, Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHandler objectInfos) {
+
+        if (null == versionSeriesId)
+            throw new RuntimeException("getAllVersions requires a version series id, but ist was null.");
+
+        StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
+
+        if (!(so instanceof VersionedDocument))
+            throw new RuntimeException("Object is not instance of a VersionedDocument (version series)");
+
+        VersionedDocument verDoc = (VersionedDocument) so;
+        List<ObjectData> res = new ArrayList<ObjectData>();
+        List<DocumentVersion> versions = verDoc.getAllVersions();
+        for (DocumentVersion version : versions) {
+            ObjectData objData = getObject(context, repositoryId, version.getId(), filter, includeAllowableActions,
+                    extension, objectInfos);
+            res.add(objData);
+        }
+
+        // provide information for Atom links for version series:
+        if (context.isObjectInfoRequired()) {
+            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
+            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
+            objectInfos.addObjectInfo(objectInfo);
+        }
+
+        return res;
+    }
+
+    public ObjectData getObjectOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
+            Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+            String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension,
+            ObjectInfoHandler objectInfos) {
+
+        StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
+        ObjectData objData = null;
+
+        if (so instanceof VersionedDocument) {
+            VersionedDocument verDoc = (VersionedDocument) so;
+            DocumentVersion latestVersion = verDoc.getLatestVersion(major);
+            objData = getObject(context, repositoryId, latestVersion.getId(), filter, includeAllowableActions,
+                    extension, objectInfos);
+        } else if (so instanceof Document) {
+            objData = getObject(context, repositoryId, so.getId(), filter, includeAllowableActions, extension,
+                    objectInfos);
+        } else
+            throw new RuntimeException("Object is not instance of a document (version series)");
+
+        // provide information for Atom links for version series:
+        if (context.isObjectInfoRequired()) {
+            ObjectInfoImpl objectInfo = new ObjectInfoImpl();
+            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfo);
+            objectInfos.addObjectInfo(objectInfo);
+        }
+
+        return objData;
+    }
+
+    public Properties getPropertiesOfLatestVersion(CallContext context, String repositoryId, String versionSeriesId,
+            Boolean major, String filter, ExtensionsData extension) {
+
+        StoredObject so = checkStandardParameters(repositoryId, versionSeriesId);
+        StoredObject latestVersionObject = null;
+
+        if (so instanceof VersionedDocument) {
+            VersionedDocument verDoc = (VersionedDocument) so;
+            latestVersionObject = verDoc.getLatestVersion(major);
+        } else if (so instanceof Document) {
+            latestVersionObject = so;
+        } else
+            throw new RuntimeException("Object is not instance of a document (version series)");
+
+        List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+        TypeDefinition td = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
+        Properties props = PropertyCreationHelper.getPropertiesFromObject(latestVersionObject, td, 
+                requestedIds);
+
+        return props;
+    }
+
+    private ObjectData getObject(CallContext context, String repositoryId, String objectId, String filter,
+            Boolean includeAllowableActions, ExtensionsData extension, ObjectInfoHandler objectInfos) {
+
+        return fObjectService.getObject(context, repositoryId, objectId, filter, includeAllowableActions,
+                IncludeRelationships.NONE, null, false, includeAllowableActions, extension, objectInfos);
+    }
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryVersioningServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Filing.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Filing.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Filing.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Filing.java Thu Jul 29 17:13:28 2010
@@ -1,67 +1,67 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory.storedobj.api;
-
-import java.util.List;
-
-/**
- * Path is the capability of an object to get accessed by a path in addition to
- * the identifier. Paths are hierarchical, each object with a path has a parent
- * where the parent is always a folder. Paths do not exist on its own but are
- * part of other objects (documents and folders). Most of the functionality is
- * defined in interfaces that are subclasses.
- * 
- * @author Jens
- */
-public interface Filing {
-
-    /**
-     * character indicating how folders are separated within a path string. This
-     * char must not be a valid character of an object name.
-     */
-    public static final String PATH_SEPARATOR = "/";
-
-    /**
-     * return a list of parents. for single parent object this list must contain
-     * only one element. returns an empty list if this is an unfiled document.
-     * 
-     * @return list of parent folders
-     */
-    List<Folder> getParents();
-    
-    /**
-     * usually true except for the root folder, optimized call that just tests
-     * existence to provide information for AtomPub links (much cheaper than
-     * calling getParents() and test for empty result.
-     * 
-     * @return
-     *    true if object has a parent, false if it is a root object
-     */
-    boolean hasParent();
-
-    /**
-     * Move an object to a different folder. Source and target object are
-     * persisted in this call as part of a transactional step.
-     * 
-     * @param newParent
-     *            new parent folder for the object
-     */
-    public void move(Folder oldParent, Folder newParent);
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.api;
+
+import java.util.List;
+
+/**
+ * Path is the capability of an object to get accessed by a path in addition to
+ * the identifier. Paths are hierarchical, each object with a path has a parent
+ * where the parent is always a folder. Paths do not exist on its own but are
+ * part of other objects (documents and folders). Most of the functionality is
+ * defined in interfaces that are subclasses.
+ * 
+ * @author Jens
+ */
+public interface Filing {
+
+    /**
+     * character indicating how folders are separated within a path string. This
+     * char must not be a valid character of an object name.
+     */
+    public static final String PATH_SEPARATOR = "/";
+
+    /**
+     * return a list of parents. for single parent object this list must contain
+     * only one element. returns an empty list if this is an unfiled document.
+     * 
+     * @return list of parent folders
+     */
+    List<Folder> getParents();
+    
+    /**
+     * usually true except for the root folder, optimized call that just tests
+     * existence to provide information for AtomPub links (much cheaper than
+     * calling getParents() and test for empty result.
+     * 
+     * @return
+     *    true if object has a parent, false if it is a root object
+     */
+    boolean hasParent();
+
+    /**
+     * Move an object to a different folder. Source and target object are
+     * persisted in this call as part of a transactional step.
+     * 
+     * @param newParent
+     *            new parent folder for the object
+     */
+    public void move(Folder oldParent, Folder newParent);
+
 }
\ No newline at end of file

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/Filing.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/MultiFiling.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/MultiFiling.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/MultiFiling.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/MultiFiling.java Thu Jul 29 17:13:28 2010
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory.storedobj.api;
-
-
-/**
- * Documents can have in the CMIS specification multiple parents. This interface
- * describes the behavior of objects with multiple parent objects.
- * 
- * @author Jens
- * 
- */
-public interface MultiFiling extends Filing {
-
-    /**
-     * retrieve the path segment of this folder
-     * 
-     * @return
-     */
-    String getPathSegment();
-
-    /**
-     * Add this document to a new parent folder as child object
-     * 
-     * @param parent
-     *            new parent folder of the document.
-     */
-    void addParent(Folder parent);
-
-    /**
-     * Remove this object from the children of parent
-     * 
-     * @param parent
-     *            parent folder of the document
-     */
-    void removeParent(Folder parent);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.api;
+
+
+/**
+ * Documents can have in the CMIS specification multiple parents. This interface
+ * describes the behavior of objects with multiple parent objects.
+ * 
+ * @author Jens
+ * 
+ */
+public interface MultiFiling extends Filing {
+
+    /**
+     * retrieve the path segment of this folder
+     * 
+     * @return
+     */
+    String getPathSegment();
+
+    /**
+     * Add this document to a new parent folder as child object
+     * 
+     * @param parent
+     *            new parent folder of the document.
+     */
+    void addParent(Folder parent);
+
+    /**
+     * Remove this object from the children of parent
+     * 
+     * @param parent
+     *            parent folder of the document
+     */
+    void removeParent(Folder parent);
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/MultiFiling.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/SingleFiling.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/SingleFiling.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/SingleFiling.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/SingleFiling.java Thu Jul 29 17:13:28 2010
@@ -1,51 +1,51 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory.storedobj.api;
-
-/**
- * Folders have in the CMIS specification exactly one parent. This interface
- * describes the behavior of objects with a single parent object.
- * 
- * @author Jens
- * 
- */
-public interface SingleFiling extends Filing {
-
-    /**
-     * @return
-     */
-    String getPath();
-
-    /**
-     * @return
-     */
-    Folder getParent();
-
-    /**
-     * Put the document in a folder and set the parent. This method should not
-     * be used to file a document in a folder. It is used internally when a
-     * document is filed to the folder. The document does not get persisted in
-     * this call.
-     * 
-     * @param parent
-     *            parent folder of the document to be assigned.
-     */
-    void setParent(Folder parent);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.api;
+
+/**
+ * Folders have in the CMIS specification exactly one parent. This interface
+ * describes the behavior of objects with a single parent object.
+ * 
+ * @author Jens
+ * 
+ */
+public interface SingleFiling extends Filing {
+
+    /**
+     * @return
+     */
+    String getPath();
+
+    /**
+     * @return
+     */
+    Folder getParent();
+
+    /**
+     * Put the document in a folder and set the parent. This method should not
+     * be used to file a document in a folder. It is used internally when a
+     * document is filed to the folder. The document does not get persisted in
+     * this call.
+     * 
+     * @param parent
+     *            parent folder of the document to be assigned.
+     */
+    void setParent(Folder parent);
+
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/SingleFiling.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java Thu Jul 29 17:13:28 2010
@@ -1,156 +1,156 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
-import org.apache.chemistry.opencmis.inmemory.NameValidator;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling;
-
-/**
- * @author Jens
- * 
- *         AbstractMultiPathImpl is the common superclass of all objects hold in
- *         the repository that have multiple parent folders, these are: Folders
- */
-public abstract class AbstractMultiFilingImpl extends StoredObjectImpl implements MultiFiling {
-
-    protected List<Folder> fParents = new ArrayList<Folder>(1);
-
-    AbstractMultiFilingImpl(ObjectStoreImpl objStore) {
-        super(objStore);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#addParent(
-     * org.apache.opencmis.inmemory.storedobj.api.Folder)
-     */
-    public void addParent(Folder parent) {
-
-      try {
-          fObjStore.lock();
-          addParentIntern(parent);
-      } finally {
-        fObjStore.unlock();
-      }
-    }
-
-    private void addParentIntern(Folder parent) {
-
-        if (parent.hasChild(getName()))
-            throw new IllegalArgumentException(
-                    "Cannot assign new parent folder, this name already exists in target folder.");
-
-        if (null == fParents)
-            fParents = new ArrayList<Folder>();
-
-        fParents.add(parent);
-      }
-    
-    
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#removeParent
-     * (org.apache.opencmis.inmemory.storedobj.api.Folder)
-     */
-    public void removeParent(Folder parent) {
-        try {
-            fObjStore.lock();
-            removeParentIntern(parent);
-        } finally {
-          fObjStore.unlock();
-        }
-    }
-
-    private void removeParentIntern(Folder parent) {
-        fParents.remove(parent);
-        if (fParents.isEmpty())
-            fParents = null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getParents()
-     */
-    public List<Folder> getParents() {
-        return fParents;
-    }
-
-    public boolean hasParent() {
-      return null != fParents && !fParents.isEmpty();
-    }
-      
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getPathSegment
-     * ()
-     */
-    public String getPathSegment() {
-        return getName();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.inmemory.storedobj.api.Path#move(org.apache.opencmis
-     * .inmemory.storedobj.api.Folder,
-     * org.apache.opencmis.inmemory.storedobj.api.Folder)
-     */
-    public void move(Folder oldParent, Folder newParent) {
-        try {
-            fObjStore.lock();
-            addParentIntern(newParent);
-            removeParentIntern(oldParent);
-        } finally {
-          fObjStore.unlock();
-        }
-    }
-
-    public void rename(String newName) {
-        try {
-            if (!NameValidator.isValidId(newName))
-                throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-            fObjStore.lock();
-            for (Folder folder : fParents) {
-              if (folder == null)
-                  throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
-              if (folder.hasChild(newName))
-                  throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
-                          + ". This path already exists in parent " + folder.getPath() + ".");
-            }
-            setName(newName);
-        } finally {
-          fObjStore.unlock();
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
+import org.apache.chemistry.opencmis.inmemory.NameValidator;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.MultiFiling;
+
+/**
+ * @author Jens
+ * 
+ *         AbstractMultiPathImpl is the common superclass of all objects hold in
+ *         the repository that have multiple parent folders, these are: Folders
+ */
+public abstract class AbstractMultiFilingImpl extends StoredObjectImpl implements MultiFiling {
+
+    protected List<Folder> fParents = new ArrayList<Folder>(1);
+
+    AbstractMultiFilingImpl(ObjectStoreImpl objStore) {
+        super(objStore);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#addParent(
+     * org.apache.opencmis.inmemory.storedobj.api.Folder)
+     */
+    public void addParent(Folder parent) {
+
+      try {
+          fObjStore.lock();
+          addParentIntern(parent);
+      } finally {
+        fObjStore.unlock();
+      }
+    }
+
+    private void addParentIntern(Folder parent) {
+
+        if (parent.hasChild(getName()))
+            throw new IllegalArgumentException(
+                    "Cannot assign new parent folder, this name already exists in target folder.");
+
+        if (null == fParents)
+            fParents = new ArrayList<Folder>();
+
+        fParents.add(parent);
+      }
+    
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#removeParent
+     * (org.apache.opencmis.inmemory.storedobj.api.Folder)
+     */
+    public void removeParent(Folder parent) {
+        try {
+            fObjStore.lock();
+            removeParentIntern(parent);
+        } finally {
+          fObjStore.unlock();
+        }
+    }
+
+    private void removeParentIntern(Folder parent) {
+        fParents.remove(parent);
+        if (fParents.isEmpty())
+            fParents = null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getParents()
+     */
+    public List<Folder> getParents() {
+        return fParents;
+    }
+
+    public boolean hasParent() {
+      return null != fParents && !fParents.isEmpty();
+    }
+      
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.inmemory.storedobj.api.MultiParentPath#getPathSegment
+     * ()
+     */
+    public String getPathSegment() {
+        return getName();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.opencmis.inmemory.storedobj.api.Path#move(org.apache.opencmis
+     * .inmemory.storedobj.api.Folder,
+     * org.apache.opencmis.inmemory.storedobj.api.Folder)
+     */
+    public void move(Folder oldParent, Folder newParent) {
+        try {
+            fObjStore.lock();
+            addParentIntern(newParent);
+            removeParentIntern(oldParent);
+        } finally {
+          fObjStore.unlock();
+        }
+    }
+
+    public void rename(String newName) {
+        try {
+            if (!NameValidator.isValidId(newName))
+                throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+            fObjStore.lock();
+            for (Folder folder : fParents) {
+              if (folder == null)
+                  throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
+              if (folder.hasChild(newName))
+                  throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
+                          + ". This path already exists in parent " + folder.getPath() + ".");
+            }
+            setName(newName);
+        } finally {
+          fObjStore.unlock();
+        }
+    }
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractMultiFilingImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java Thu Jul 29 17:13:28 2010
@@ -1,151 +1,151 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
-import org.apache.chemistry.opencmis.inmemory.NameValidator;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.SingleFiling;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
-
-/**
- * 
- * @author Jens
- * 
- *         AbstractPathImpl is the common superclass of all objects hold in the
- *         repository that have a single parent, these are: Folders
- * 
- */
-
-public abstract class AbstractSingleFilingImpl extends StoredObjectImpl implements SingleFiling {
-
-    protected FolderImpl fParent;
-
-    protected AbstractSingleFilingImpl(ObjectStoreImpl objStore) {
-        super(objStore);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
-     */
-    public String getPath() {
-        StringBuffer path = new StringBuffer(getName());
-        if (null == getParent())
-            path.replace(0, path.length(), PATH_SEPARATOR); // root folder-->
-        // set /
-        else {
-            Folder f = getParent();
-            while (f.getParent() != null) {
-                path.insert(0, PATH_SEPARATOR);
-                path.insert(0, f.getName());
-                f = f.getParent();
-            }
-            path.insert(0, PATH_SEPARATOR);
-        }
-        // if (LOG.isDebugEnabled())
-        // LOG.debug("getPath() returns: " + path.toString());
-        return path.toString();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent
-     * ()
-     */
-    public Folder getParent() {
-        return fParent;
-    }
-
-    public boolean hasParent() {
-      return null != fParent;
-    }
-
-    public List<Folder> getParents() {
-        if (null == fParent)
-            return Collections.emptyList();
-        else
-            return Collections.singletonList((Folder) fParent);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath
-     * #
-     * setParent(org.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
-     */
-    public void setParent(Folder parent) {
-        try {
-            fObjStore.lock();
-            fParent = (FolderImpl) parent;
-        } finally {
-          fObjStore.unlock();
-        }
-    }
-
-    public void rename(String newName) {
-        if (!NameValidator.isValidId(newName))
-            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
-        try {
-            fObjStore.lock();
-            if (getParent() == null)
-                throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
-            if (getParent().hasChild(newName))
-                throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
-                        + ". This path already exists.");
-
-            setName(newName);
-        } finally {
-          fObjStore.unlock();
-        }
-    }
-
-    public void move(Folder oldParent, Folder newParent) {
-
-        try {
-            fObjStore.lock();
-            if (this instanceof Document || this instanceof VersionedDocument)
-                fParent.moveChildDocument(this, oldParent, newParent);
-            else {// it must be a folder
-                if (getParent() == null)
-                    throw new IllegalArgumentException("Root folder cannot be moved.");
-                if (newParent == null)
-                    throw new IllegalArgumentException("null is not a valid move target.");
-                if (newParent.hasChild(getName()))
-                    throw new IllegalArgumentException("Cannot move folder, this name already exists in target.");
-
-                setParent(newParent);
-            }
-        } finally {
-          fObjStore.unlock();
-        }
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
+import org.apache.chemistry.opencmis.inmemory.NameValidator;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Document;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.SingleFiling;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.VersionedDocument;
+
+/**
+ * 
+ * @author Jens
+ * 
+ *         AbstractPathImpl is the common superclass of all objects hold in the
+ *         repository that have a single parent, these are: Folders
+ * 
+ */
+
+public abstract class AbstractSingleFilingImpl extends StoredObjectImpl implements SingleFiling {
+
+    protected FolderImpl fParent;
+
+    protected AbstractSingleFilingImpl(ObjectStoreImpl objStore) {
+        super(objStore);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getPath()
+     */
+    public String getPath() {
+        StringBuffer path = new StringBuffer(getName());
+        if (null == getParent())
+            path.replace(0, path.length(), PATH_SEPARATOR); // root folder-->
+        // set /
+        else {
+            Folder f = getParent();
+            while (f.getParent() != null) {
+                path.insert(0, PATH_SEPARATOR);
+                path.insert(0, f.getName());
+                f = f.getParent();
+            }
+            path.insert(0, PATH_SEPARATOR);
+        }
+        // if (LOG.isDebugEnabled())
+        // LOG.debug("getPath() returns: " + path.toString());
+        return path.toString();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.opencmis.client.provider.spi.inmemory.StoredObjectWithPath#getParent
+     * ()
+     */
+    public Folder getParent() {
+        return fParent;
+    }
+
+    public boolean hasParent() {
+      return null != fParent;
+    }
+
+    public List<Folder> getParents() {
+        if (null == fParent)
+            return Collections.emptyList();
+        else
+            return Collections.singletonList((Folder) fParent);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.opencmis.client.provider.spi.inmemory.storedobj.api.StoredObjectWithPath
+     * #
+     * setParent(org.opencmis.client.provider.spi.inmemory.storedobj.api.Folder)
+     */
+    public void setParent(Folder parent) {
+        try {
+            fObjStore.lock();
+            fParent = (FolderImpl) parent;
+        } finally {
+          fObjStore.unlock();
+        }
+    }
+
+    public void rename(String newName) {
+        if (!NameValidator.isValidId(newName))
+            throw new CmisInvalidArgumentException(NameValidator.ERROR_ILLEGAL_NAME);
+        try {
+            fObjStore.lock();
+            if (getParent() == null)
+                throw new CmisInvalidArgumentException("Root folder cannot be renamed.");
+            if (getParent().hasChild(newName))
+                throw new CmisNameConstraintViolationException("Cannot rename object to " + newName
+                        + ". This path already exists.");
+
+            setName(newName);
+        } finally {
+          fObjStore.unlock();
+        }
+    }
+
+    public void move(Folder oldParent, Folder newParent) {
+
+        try {
+            fObjStore.lock();
+            if (this instanceof Document || this instanceof VersionedDocument)
+                fParent.moveChildDocument(this, oldParent, newParent);
+            else {// it must be a folder
+                if (getParent() == null)
+                    throw new IllegalArgumentException("Root folder cannot be moved.");
+                if (newParent == null)
+                    throw new IllegalArgumentException("null is not a valid move target.");
+                if (newParent.hasChild(getName()))
+                    throw new IllegalArgumentException("Cannot move folder, this name already exists in target.");
+
+                setParent(newParent);
+            }
+        } finally {
+          fObjStore.unlock();
+        }
+    }
+
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/AbstractSingleFilingImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/AbstractServiceTst.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java?rev=980513&r1=980512&r2=980513&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java Thu Jul 29 17:13:28 2010
@@ -1,285 +1,285 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.chemistry.opencmis.inmemory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.data.ObjectData;
-import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
-import org.apache.chemistry.opencmis.commons.data.Properties;
-import org.apache.chemistry.opencmis.commons.data.PropertyData;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
-import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MultiFilingTest extends AbstractServiceTst {
-
-    private static Log LOG = LogFactory.getLog(MultiFilingTest.class);
-    private static final String DOCUMENT_TYPE_ID = UnitTestTypeSystemCreator.COMPLEX_TYPE;
-    private static final String FOLDER_TYPE_ID = InMemoryFolderTypeDefinition.getRootFolderType().getId();
-    private static final String UNFILED_DOC_NAME = "Unfiled document";
-    private static final String RENAMED_DOC_NAME = "My Renamed Document";
-
-    private String fId1;
-    private String fId2;
-    private String fId11;
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-    @Test
-    public void testCreateUnfiledDocument() {
-        LOG.debug("Begin testCreatUnfiledDocument()");
-        String docId = createUnfiledDocument();
-        String docId2 = getDocument(docId);
-        assertEquals(docId, docId2);
-
-        // get object parents, must be empty
-        List<ObjectParentData> res = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
-                IncludeRelationships.NONE, null, true, null);
-
-        assertNotNull(res);
-        assertEquals(res.size(), 0);
-
-        LOG.debug("End testCreatUnfiledDocument()");
-    }
-
-    @Test
-    public void testMakeFiledDocumentUnfiled() {
-        LOG.debug("Begin testMakeFiledDocumentUnfiled()");
-
-        String docId = createDocument("Filed document", fRootFolderId, DOCUMENT_TYPE_ID, true);
-
-        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fRootFolderId, null);
-        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
-                IncludeRelationships.NONE, null, true, null);
-        assertEquals(0, parents.size());
-
-        LOG.debug("End testMakeFiledDocumentUnfiled()");
-    }
-
-    @Test
-    public void testAddDocumentToFolder() {
-        LOG.debug("Begin testAddDocumentToFolder()");
-        String docId = createUnfiledDocument();
-        addDocumentToFolder(docId);
-        LOG.debug("End testAddDocumentToFolder()");
-    }
-
-    @Test
-    public void testRemoveDocumentFromFolder() {
-        LOG.debug("Begin testRemoveDocumentFromFolder()");
-
-        String docId = createUnfiledDocument();
-        removeDocumentFromFolder(docId);
-        LOG.debug("End testRemoveDocumentFromFolder()");
-    }
-
-    @Test
-    public void testMoveMultiFiledDocument() {
-        LOG.debug("begin testMoveMultiFiledDocument()");
-        String docId = createUnfiledDocument();
-        prepareMultiFiledDocument(docId);
-        String newFolderId = createFolder("folder2.1", fId2, FOLDER_TYPE_ID);
-
-        Holder<String> idHolder = new Holder<String>(docId);
-        fObjSvc.moveObject(fRepositoryId, idHolder, newFolderId, fId11, null);
-        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
-                IncludeRelationships.NONE, null, true, null);
-        assertEquals(3, parents.size());
-        boolean foundNewParent = false;
-        boolean foundOldParent = false;
-        for (ObjectParentData parentData : parents) {
-            if (parentData.getObject().getId().equals(newFolderId))
-                foundNewParent = true;
-            if (parentData.getObject().getId().equals(fId11))
-                foundOldParent = true;
-        }
-        assertTrue("After move new target should be a parent", foundNewParent);
-        assertFalse("After move old source should no longer be a parent", foundOldParent);
-        LOG.debug("End testMoveMultiFiledDocument()");
-    }
-
-    @Test
-    public void testRenameMultiFiledDocument() {
-        LOG.debug("begin testRenameMultiFiledDocument()");
-        String docId = createUnfiledDocument();
-        prepareMultiFiledDocument(docId);
-        renameDocumentAndCheckResult(docId);
-        LOG.debug("End testRenameMultiFiledDocument()");
-    }
-
-    @Test
-    public void testRenameMultiFiledDocumentWithNameConflict() {
-        LOG.debug("begin testRenameMultiFiledDocument()");
-        String docId = createUnfiledDocument();
-        prepareMultiFiledDocument(docId);
-        // create a document with the new name in one of the folders
-        createDocument(RENAMED_DOC_NAME, fId11, DOCUMENT_TYPE_ID, true);
-        // try to rename which should fail now
-        try {
-            renameDocumentAndCheckResult(docId);
-            fail("A rename to an existing name in one of the filed folders should fail");
-        } catch (Exception e) {
-            assertTrue(e instanceof CmisNameConstraintViolationException);
-        }
-        LOG.debug("End testRenameMultiFiledDocument()");
-    }
-
-    @Test
-    public void testAddVersionedDocumentToFolder() {
-        LOG.debug("Begin testAddVersionedDocumentToFolder()");
-        String docId = createVersionedDocument();
-        addDocumentToFolder(docId);
-        LOG.debug("End testAddVersionedDocumentToFolder()");
-    }
-
-    @Test
-    public void testRemoveVersionedDocumentFromFolder() {
-        LOG.debug("Begin testRemoveVersionedDocumentFromFolder()");
-
-        String docId = createVersionedDocument();
-        removeDocumentFromFolder(docId);
-        LOG.debug("End testRemoveVersionedDocumentFromFolder()");
-    }
-
-    private void createFolders() {
-        fId1 = createFolder("folder1", fRootFolderId, FOLDER_TYPE_ID);
-        fId2 = createFolder("folder2", fRootFolderId, FOLDER_TYPE_ID);
-        fId11 = createFolder("folder1.1", fId1, FOLDER_TYPE_ID);
-    }
-
-    private void addDocumentToFolder(String docId) {
-
-        List<String> folderIds = prepareMultiFiledDocument(docId);
-
-        // get object parents, must contain all folders
-        List<ObjectParentData> res = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
-                IncludeRelationships.NONE, null, true, null);
-        assertEquals(3, res.size());
-        for (ObjectParentData opd : res) {
-            assertTrue(folderIds.contains(opd.getObject().getId()));
-            assertEquals(BaseTypeId.CMIS_FOLDER, opd.getObject().getBaseTypeId());
-            assertEquals(UNFILED_DOC_NAME, opd.getRelativePathSegment());
-        }
-
-        // try version specific filing, should fail
-        try {
-            fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId1, false, null);
-            fail("Adding not all versions to a folder should fail.");
-        } catch (Exception e) {
-            assertTrue(e instanceof CmisNotSupportedException);
-        }
-    }
-
-    private void removeDocumentFromFolder(String docId) {
-        prepareMultiFiledDocument(docId);
-
-        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fId1, null);
-        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
-                IncludeRelationships.NONE, null, true, null);
-        assertEquals(2, parents.size());
-        for (ObjectParentData opd : parents) {
-            assertFalse(fId1.equals(opd.getObject().getId()));
-        }
-
-        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fId2, null);
-        parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false, IncludeRelationships.NONE, null, true,
-                null);
-        assertEquals(1, parents.size());
-        for (ObjectParentData opd : parents) {
-            assertFalse(fId1.equals(opd.getObject().getId()));
-        }
-
-        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fId11, null);
-        parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false, IncludeRelationships.NONE, null, true,
-                null);
-        assertEquals(0, parents.size());
-    }
-
-    private String createUnfiledDocument() {
-        return createDocument(UNFILED_DOC_NAME, null, DOCUMENT_TYPE_ID, true);
-    }
-
-    private List<String> prepareMultiFiledDocument(String docId) {
-        createFolders();
-
-        // add the document to three folders
-        fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId1, true, null);
-        fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId2, true, null);
-        fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId11, true, null);
-
-        List<String> folderIds = new ArrayList<String>();
-        folderIds.add(fId1);
-        folderIds.add(fId2);
-        folderIds.add(fId11);
-
-        return folderIds;
-    }
-
-    private void renameDocumentAndCheckResult(String docId) {
-        Holder<String> idHolder = new Holder<String>(docId);
-        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
-        properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, RENAMED_DOC_NAME));
-        Properties newProps = fFactory.createPropertiesData(properties);
-        Holder<String> changeTokenHolder = new Holder<String>();
-        fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
-        docId = idHolder.getValue();
-        ObjectData res = fObjSvc.getObject(fRepositoryId, docId, "*", false, IncludeRelationships.NONE, null, false,
-                false, null);
-        assertNotNull(res);
-        Map<String, PropertyData<?>> propMap = res.getProperties().getProperties();
-        PropertyData<?> pd = propMap.get(PropertyIds.NAME);
-        assertNotNull(pd);
-        assertEquals(RENAMED_DOC_NAME, pd.getFirstValue());
-    }
-
-    private String createVersionedDocument() {
-
-        return createDocument(UNFILED_DOC_NAME, null, UnitTestTypeSystemCreator.VERSION_DOCUMENT_TYPE_ID,
-                VersioningState.MAJOR, true);
-
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.chemistry.opencmis.inmemory;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.ObjectData;
+import org.apache.chemistry.opencmis.commons.data.ObjectParentData;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class MultiFilingTest extends AbstractServiceTst {
+
+    private static Log LOG = LogFactory.getLog(MultiFilingTest.class);
+    private static final String DOCUMENT_TYPE_ID = UnitTestTypeSystemCreator.COMPLEX_TYPE;
+    private static final String FOLDER_TYPE_ID = InMemoryFolderTypeDefinition.getRootFolderType().getId();
+    private static final String UNFILED_DOC_NAME = "Unfiled document";
+    private static final String RENAMED_DOC_NAME = "My Renamed Document";
+
+    private String fId1;
+    private String fId2;
+    private String fId11;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    @Test
+    public void testCreateUnfiledDocument() {
+        LOG.debug("Begin testCreatUnfiledDocument()");
+        String docId = createUnfiledDocument();
+        String docId2 = getDocument(docId);
+        assertEquals(docId, docId2);
+
+        // get object parents, must be empty
+        List<ObjectParentData> res = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
+                IncludeRelationships.NONE, null, true, null);
+
+        assertNotNull(res);
+        assertEquals(res.size(), 0);
+
+        LOG.debug("End testCreatUnfiledDocument()");
+    }
+
+    @Test
+    public void testMakeFiledDocumentUnfiled() {
+        LOG.debug("Begin testMakeFiledDocumentUnfiled()");
+
+        String docId = createDocument("Filed document", fRootFolderId, DOCUMENT_TYPE_ID, true);
+
+        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fRootFolderId, null);
+        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
+                IncludeRelationships.NONE, null, true, null);
+        assertEquals(0, parents.size());
+
+        LOG.debug("End testMakeFiledDocumentUnfiled()");
+    }
+
+    @Test
+    public void testAddDocumentToFolder() {
+        LOG.debug("Begin testAddDocumentToFolder()");
+        String docId = createUnfiledDocument();
+        addDocumentToFolder(docId);
+        LOG.debug("End testAddDocumentToFolder()");
+    }
+
+    @Test
+    public void testRemoveDocumentFromFolder() {
+        LOG.debug("Begin testRemoveDocumentFromFolder()");
+
+        String docId = createUnfiledDocument();
+        removeDocumentFromFolder(docId);
+        LOG.debug("End testRemoveDocumentFromFolder()");
+    }
+
+    @Test
+    public void testMoveMultiFiledDocument() {
+        LOG.debug("begin testMoveMultiFiledDocument()");
+        String docId = createUnfiledDocument();
+        prepareMultiFiledDocument(docId);
+        String newFolderId = createFolder("folder2.1", fId2, FOLDER_TYPE_ID);
+
+        Holder<String> idHolder = new Holder<String>(docId);
+        fObjSvc.moveObject(fRepositoryId, idHolder, newFolderId, fId11, null);
+        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
+                IncludeRelationships.NONE, null, true, null);
+        assertEquals(3, parents.size());
+        boolean foundNewParent = false;
+        boolean foundOldParent = false;
+        for (ObjectParentData parentData : parents) {
+            if (parentData.getObject().getId().equals(newFolderId))
+                foundNewParent = true;
+            if (parentData.getObject().getId().equals(fId11))
+                foundOldParent = true;
+        }
+        assertTrue("After move new target should be a parent", foundNewParent);
+        assertFalse("After move old source should no longer be a parent", foundOldParent);
+        LOG.debug("End testMoveMultiFiledDocument()");
+    }
+
+    @Test
+    public void testRenameMultiFiledDocument() {
+        LOG.debug("begin testRenameMultiFiledDocument()");
+        String docId = createUnfiledDocument();
+        prepareMultiFiledDocument(docId);
+        renameDocumentAndCheckResult(docId);
+        LOG.debug("End testRenameMultiFiledDocument()");
+    }
+
+    @Test
+    public void testRenameMultiFiledDocumentWithNameConflict() {
+        LOG.debug("begin testRenameMultiFiledDocument()");
+        String docId = createUnfiledDocument();
+        prepareMultiFiledDocument(docId);
+        // create a document with the new name in one of the folders
+        createDocument(RENAMED_DOC_NAME, fId11, DOCUMENT_TYPE_ID, true);
+        // try to rename which should fail now
+        try {
+            renameDocumentAndCheckResult(docId);
+            fail("A rename to an existing name in one of the filed folders should fail");
+        } catch (Exception e) {
+            assertTrue(e instanceof CmisNameConstraintViolationException);
+        }
+        LOG.debug("End testRenameMultiFiledDocument()");
+    }
+
+    @Test
+    public void testAddVersionedDocumentToFolder() {
+        LOG.debug("Begin testAddVersionedDocumentToFolder()");
+        String docId = createVersionedDocument();
+        addDocumentToFolder(docId);
+        LOG.debug("End testAddVersionedDocumentToFolder()");
+    }
+
+    @Test
+    public void testRemoveVersionedDocumentFromFolder() {
+        LOG.debug("Begin testRemoveVersionedDocumentFromFolder()");
+
+        String docId = createVersionedDocument();
+        removeDocumentFromFolder(docId);
+        LOG.debug("End testRemoveVersionedDocumentFromFolder()");
+    }
+
+    private void createFolders() {
+        fId1 = createFolder("folder1", fRootFolderId, FOLDER_TYPE_ID);
+        fId2 = createFolder("folder2", fRootFolderId, FOLDER_TYPE_ID);
+        fId11 = createFolder("folder1.1", fId1, FOLDER_TYPE_ID);
+    }
+
+    private void addDocumentToFolder(String docId) {
+
+        List<String> folderIds = prepareMultiFiledDocument(docId);
+
+        // get object parents, must contain all folders
+        List<ObjectParentData> res = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
+                IncludeRelationships.NONE, null, true, null);
+        assertEquals(3, res.size());
+        for (ObjectParentData opd : res) {
+            assertTrue(folderIds.contains(opd.getObject().getId()));
+            assertEquals(BaseTypeId.CMIS_FOLDER, opd.getObject().getBaseTypeId());
+            assertEquals(UNFILED_DOC_NAME, opd.getRelativePathSegment());
+        }
+
+        // try version specific filing, should fail
+        try {
+            fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId1, false, null);
+            fail("Adding not all versions to a folder should fail.");
+        } catch (Exception e) {
+            assertTrue(e instanceof CmisNotSupportedException);
+        }
+    }
+
+    private void removeDocumentFromFolder(String docId) {
+        prepareMultiFiledDocument(docId);
+
+        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fId1, null);
+        List<ObjectParentData> parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false,
+                IncludeRelationships.NONE, null, true, null);
+        assertEquals(2, parents.size());
+        for (ObjectParentData opd : parents) {
+            assertFalse(fId1.equals(opd.getObject().getId()));
+        }
+
+        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fId2, null);
+        parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false, IncludeRelationships.NONE, null, true,
+                null);
+        assertEquals(1, parents.size());
+        for (ObjectParentData opd : parents) {
+            assertFalse(fId1.equals(opd.getObject().getId()));
+        }
+
+        fMultiSvc.removeObjectFromFolder(fRepositoryId, docId, fId11, null);
+        parents = fNavSvc.getObjectParents(fRepositoryId, docId, "*", false, IncludeRelationships.NONE, null, true,
+                null);
+        assertEquals(0, parents.size());
+    }
+
+    private String createUnfiledDocument() {
+        return createDocument(UNFILED_DOC_NAME, null, DOCUMENT_TYPE_ID, true);
+    }
+
+    private List<String> prepareMultiFiledDocument(String docId) {
+        createFolders();
+
+        // add the document to three folders
+        fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId1, true, null);
+        fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId2, true, null);
+        fMultiSvc.addObjectToFolder(fRepositoryId, docId, fId11, true, null);
+
+        List<String> folderIds = new ArrayList<String>();
+        folderIds.add(fId1);
+        folderIds.add(fId2);
+        folderIds.add(fId11);
+
+        return folderIds;
+    }
+
+    private void renameDocumentAndCheckResult(String docId) {
+        Holder<String> idHolder = new Holder<String>(docId);
+        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+        properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, RENAMED_DOC_NAME));
+        Properties newProps = fFactory.createPropertiesData(properties);
+        Holder<String> changeTokenHolder = new Holder<String>();
+        fObjSvc.updateProperties(fRepositoryId, idHolder, changeTokenHolder, newProps, null);
+        docId = idHolder.getValue();
+        ObjectData res = fObjSvc.getObject(fRepositoryId, docId, "*", false, IncludeRelationships.NONE, null, false,
+                false, null);
+        assertNotNull(res);
+        Map<String, PropertyData<?>> propMap = res.getProperties().getProperties();
+        PropertyData<?> pd = propMap.get(PropertyIds.NAME);
+        assertNotNull(pd);
+        assertEquals(RENAMED_DOC_NAME, pd.getFirstValue());
+    }
+
+    private String createVersionedDocument() {
+
+        return createDocument(UNFILED_DOC_NAME, null, UnitTestTypeSystemCreator.VERSION_DOCUMENT_TYPE_ID,
+                VersioningState.MAJOR, true);
+
+    }
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/MultiFilingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message