chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r918000 - in /incubator/chemistry/trunk/opencmis: opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/ opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ opencmis-client...
Date Tue, 02 Mar 2010 12:35:11 GMT
Author: fmui
Date: Tue Mar  2 12:35:10 2010
New Revision: 918000

URL: http://svn.apache.org/viewvc?rev=918000&view=rev
Log:
added more client API code
added a few more lines of test code and cleaned up a bit

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/CmisObject.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentCmisObject.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/HttpUtils.java
    incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/test/java/org/apache/opencmis/client/provider/framework/AbstractSimpleReadOnlyTests.java
    incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/sample/AbstractSampleIT.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/CmisObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/CmisObject.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/CmisObject.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/CmisObject.java
Tue Mar  2 12:35:10 2010
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.client.api.util.PagingList;
 import org.apache.opencmis.commons.enums.AclPropagation;
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.commons.enums.RelationshipDirection;
@@ -133,8 +134,9 @@
 
   // relationship service
 
-  List<Relationship> getRelationships(boolean includeSubRelationshipTypes,
-      RelationshipDirection relationshipDirection, ObjectType type);
+  PagingList<Relationship> getRelationships(boolean includeSubRelationshipTypes,
+      RelationshipDirection relationshipDirection, ObjectType type, String filter, 
+      Boolean includeAllowableActions, int itemsPerPage);
 
   // policy service
 
@@ -157,7 +159,7 @@
   void addAcl(List<Ace> addAces, AclPropagation aclPropagation);
 
   void removeAcl(List<Ace> removeAces, AclPropagation aclPropagation);
-  
+
   // buffered stuff
 
   <T> void setProperty(String id, T value);

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/Document.java
Tue Mar  2 12:35:10 2010
@@ -56,23 +56,23 @@
 
   // document specific properties
 
-  boolean isImmutable(); // cmis:isImmutable
+  Boolean isImmutable(); // cmis:isImmutable
 
-  boolean isLatestVersion(); // cmis:isLatestVersion
+  Boolean isLatestVersion(); // cmis:isLatestVersion
 
-  boolean isMajorVersion(); // cmis:isMajorVersion
+  Boolean isMajorVersion(); // cmis:isMajorVersion
 
-  boolean isLatestMajorVersion(); // cmis:isLatestMajorVersion
+  Boolean isLatestMajorVersion(); // cmis:isLatestMajorVersion
 
   String getVersionLabel(); // cmis:versionLabel
 
-  String getVersionSeries(); // cmis:versionSeriesId
+  String getVersionSeriesId(); // cmis:versionSeriesId
 
-  boolean isVersionSeriesCheckedOut(); // cmis:isVersionSeriesCheckedOut
+  Boolean isVersionSeriesCheckedOut(); // cmis:isVersionSeriesCheckedOut
 
   String getVersionSeriesCheckedOutBy(); // cmis:versionSeriesCheckedOutBy
 
-  String getVersionSeriesCheckedOut(); // cmis:versionSeriesCheckedOutId
+  String getVersionSeriesCheckedOutId(); // cmis:versionSeriesCheckedOutId
 
   void deleteAllVersions();
   

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-api/src/main/java/org/apache/opencmis/client/api/repository/ObjectFactory.java
Tue Mar  2 12:35:10 2010
@@ -24,7 +24,6 @@
 
 import org.apache.opencmis.client.api.Ace;
 import org.apache.opencmis.client.api.Acl;
-import org.apache.opencmis.client.api.AclPermission;
 import org.apache.opencmis.client.api.AllowableActions;
 import org.apache.opencmis.client.api.ContentStream;
 import org.apache.opencmis.client.api.Document;

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentCmisObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentCmisObject.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentCmisObject.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentCmisObject.java
Tue Mar  2 12:35:10 2010
@@ -18,7 +18,10 @@
  */
 package org.apache.opencmis.client.runtime;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.List;
 import java.util.Map;
@@ -31,14 +34,22 @@
 import org.apache.opencmis.client.api.Property;
 import org.apache.opencmis.client.api.Relationship;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.client.api.util.PagingList;
+import org.apache.opencmis.client.runtime.util.AbstractPagingList;
 import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.api.PropertyDefinition;
 import org.apache.opencmis.commons.enums.AclPropagation;
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.commons.enums.RelationshipDirection;
+import org.apache.opencmis.commons.enums.Updatability;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.opencmis.commons.provider.CmisProvider;
 import org.apache.opencmis.commons.provider.Holder;
 import org.apache.opencmis.commons.provider.ObjectData;
+import org.apache.opencmis.commons.provider.ObjectList;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.PropertyIdData;
+import org.apache.opencmis.commons.provider.RelationshipService;
 
 /**
  * Base class for all persistent session object impl classes.
@@ -51,6 +62,7 @@
   private AllowableActions allowableActions;
   private Acl acl;
   private List<Policy> policies;
+  private List<Relationship> relationships;
   private boolean isChanged = false;
 
   /**
@@ -66,6 +78,11 @@
       throw new IllegalArgumentException("Object type must be set!");
     }
 
+    if (objectType.getPropertyDefintions().size() >= 9) {
+      // there must be at least the 9 standard properties that all objects have
+      throw new IllegalArgumentException("Object type must have property defintions!");
+    }
+
     this.session = session;
     this.objectType = objectType;
 
@@ -97,6 +114,15 @@
           }
         }
       }
+
+      // handle relationships
+      if (objectData.getRelationships() != null) {
+        relationships = new ArrayList<Relationship>();
+        for (ObjectData rod : objectData.getRelationships()) {
+          relationships.add(new PersistentRelationshipImpl(getSession(),
+              getTypeFromObjectData(rod), rod));
+        }
+      }
     }
   }
 
@@ -134,12 +160,31 @@
   protected String getObjectId() {
     String objectId = getId();
     if (objectId == null) {
-      throw new IllegalStateException("Object Id is unknown");
+      throw new IllegalStateException("Object Id is unknown!");
     }
 
     return objectId;
   }
 
+  /**
+   * Extracts the type information from the given object data and returns the object type
or
+   * <code>null</code> if there is no type information.
+   */
+  private ObjectType getTypeFromObjectData(ObjectData objectData) {
+    if ((objectData == null) || (objectData.getProperties() == null)
+        || (objectData.getProperties().getProperties() == null)) {
+      return null;
+    }
+
+    PropertyData<?> typeProperty = objectData.getProperties().getProperties().get(
+        PropertyIds.CMIS_OBJECT_TYPE_ID);
+    if (!(typeProperty instanceof PropertyIdData)) {
+      return null;
+    }
+
+    return getSession().getTypeDefinition((String) typeProperty.getFirstValue());
+  }
+
   // --- operations ---
 
   /*
@@ -318,8 +363,7 @@
    * @see org.apache.opencmis.client.api.CmisObject#setProperty(java.lang.String, java.lang.Object)
    */
   public <T> void setProperty(String id, T value) {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    setPropertyMultivalue(id, (value == null ? null : Collections.singletonList(value)));
   }
 
   /*
@@ -328,9 +372,69 @@
    * @see org.apache.opencmis.client.api.CmisObject#setPropertyMultivalue(java.lang.String,
    * java.util.List)
    */
+  @SuppressWarnings("unchecked")
   public <T> void setPropertyMultivalue(String id, List<T> value) {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    // get and check property type
+    PropertyDefinition<?> propertyDefinition = getObjectType().getPropertyDefintions().get(id);
+    if (propertyDefinition == null) {
+      throw new IllegalArgumentException("Unknown property!");
+    }
+
+    // check updatability
+    if (propertyDefinition.getUpdatability() == Updatability.READONLY) {
+      throw new IllegalArgumentException("Property is read-only!");
+    }
+
+    boolean typeMatch = false;
+
+    if ((value == null) || (value.isEmpty())) {
+      typeMatch = true;
+      if (value.isEmpty()) {
+        value = null;
+      }
+    }
+    else {
+      // check if list contains null values
+      for (Object o : value) {
+        if (o == null) {
+          throw new IllegalArgumentException("List contains null values!");
+        }
+      }
+
+      // take a sample and test the data type
+      Object firstValue = value.get(0);
+
+      switch (propertyDefinition.getPropertyType()) {
+      case STRING:
+      case ID:
+      case URI:
+      case HTML:
+        typeMatch = (firstValue instanceof String);
+        break;
+      case INTEGER:
+        typeMatch = (firstValue instanceof BigInteger);
+        break;
+      case DECIMAL:
+        typeMatch = (firstValue instanceof BigDecimal);
+        break;
+      case BOOLEAN:
+        typeMatch = (firstValue instanceof Boolean);
+        break;
+      case DATETIME:
+        typeMatch = (firstValue instanceof GregorianCalendar);
+        break;
+      }
+    }
+
+    if (!typeMatch) {
+      throw new IllegalArgumentException("Value does not match property type!");
+    }
+
+    Property<T> newProperty = (Property<T>) getSession().getPropertyFactory()
+        .createPropertyMultivalue((PropertyDefinition<T>) propertyDefinition, value);
+
+    setChanged();
+    this.properties.put(id, newProperty);
   }
 
   /*
@@ -499,15 +603,70 @@
 
   // --- relationships ---
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.api.CmisObject#getRelationships()
+   */
   public List<Relationship> getRelationships() {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    return relationships;
   }
 
-  public List<Relationship> getRelationships(boolean includeSubRelationshipTypes,
-      RelationshipDirection relationshipDirection, ObjectType type) {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.api.CmisObject#getRelationships(boolean,
+   * org.apache.opencmis.commons.enums.RelationshipDirection,
+   * org.apache.opencmis.client.api.objecttype.ObjectType, java.lang.String, java.lang.Boolean,
int)
+   */
+  public PagingList<Relationship> getRelationships(final boolean includeSubRelationshipTypes,
+      final RelationshipDirection relationshipDirection, ObjectType type, final String filter,
+      final Boolean includeAllowableActions, final int itemsPerPage) {
+    if (itemsPerPage < 1) {
+      throw new IllegalArgumentException("itemsPerPage must be > 0!");
+    }
+
+    final String objectId = getObjectId();
+    final String typeId = (type == null ? null : type.getId());
+    final RelationshipService relationshipService = getProvider().getRelationshipService();
+
+    return new AbstractPagingList<Relationship>() {
+
+      @Override
+      protected List<Relationship> fetchPage(int pageNumber) {
+        int skipCount = pageNumber * getMaxItemsPerPage();
+
+        // fetch the relationships
+        ObjectList relList = relationshipService.getObjectRelationships(getRepositoryId(),
+            objectId, includeSubRelationshipTypes, relationshipDirection, typeId, filter,
+            includeAllowableActions, BigInteger.valueOf(getMaxItemsPerPage()), BigInteger
+                .valueOf(skipCount), null);
+
+        // set num items
+        if (relList.getNumItems() != null) {
+          setNumItems(relList.getNumItems().intValue());
+        }
+        else {
+          setNumItems(-1);
+        }
+
+        // convert relationship objects
+        List<Relationship> result = new ArrayList<Relationship>();
+        if (relList.getObjects() != null) {
+          for (ObjectData rod : relList.getObjects()) {
+            result
+                .add(new PersistentRelationshipImpl(getSession(), getTypeFromObjectData(rod),
rod));
+          }
+        }
+
+        return result;
+      }
+
+      @Override
+      public int getMaxItemsPerPage() {
+        return itemsPerPage;
+      }
+    };
   }
 
   // --- other ---

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/AbstractPersistentFilableCmisObject.java
Tue Mar  2 12:35:10 2010
@@ -18,25 +18,103 @@
  */
 package org.apache.opencmis.client.runtime;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.opencmis.client.api.CmisObject;
 import org.apache.opencmis.client.api.FileableCmisObject;
 import org.apache.opencmis.client.api.Folder;
+import org.apache.opencmis.commons.PropertyIds;
+import org.apache.opencmis.commons.enums.IncludeRelationships;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.opencmis.commons.provider.Holder;
+import org.apache.opencmis.commons.provider.ObjectParentData;
+import org.apache.opencmis.commons.provider.PropertyData;
+import org.apache.opencmis.commons.provider.PropertyIdData;
+import org.apache.opencmis.commons.provider.PropertyStringData;
 
 public abstract class AbstractPersistentFilableCmisObject extends AbstractPersistentCmisObject
     implements FileableCmisObject {
 
+  private List<Folder> parents;
+  private List<String> paths;
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.api.FileableCmisObject#getParents()
+   */
   public List<Folder> getParents() {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    if (this.parents != null) {
+      return this.parents;
+    }
+
+    // get object ids and paths of the parent folders
+    String objectId = getObjectId();
+    List<ObjectParentData> providerParents = getProvider().getNavigationService().getObjectParents(
+        getRepositoryId(), objectId, PropertyIds.CMIS_OBJECT_ID + "," + PropertyIds.CMIS_PATH,
+        false, IncludeRelationships.NONE, null, true, null);
+
+    this.parents = new ArrayList<Folder>();
+    this.paths = new ArrayList<String>();
+
+    for (ObjectParentData p : providerParents) {
+      if ((p == null) || (p.getObject() == null) || (p.getObject().getProperties() == null))
{
+        // should not happen...
+        throw new CmisRuntimeException("Repository sent invalid data!");
+      }
+
+      // get id property
+      PropertyData<?> idProperty = p.getObject().getProperties().getProperties().get(
+          PropertyIds.CMIS_OBJECT_ID);
+      if (!(idProperty instanceof PropertyIdData)) {
+        // the repository sent an object without a valid object id...
+        throw new CmisRuntimeException("Repository sent invalid data! No object id!");
+      }
+
+      // get path property
+      PropertyData<?> pathProperty = p.getObject().getProperties().getProperties().get(
+          PropertyIds.CMIS_PATH);
+      if (!(pathProperty instanceof PropertyStringData)) {
+        // the repository sent a folder without a valid path...
+        throw new CmisRuntimeException("Repository sent invalid data! No path property!");
+      }
+
+      if (p.getRelativePathSegment() == null) {
+        // the repository didn't send a relative path segment
+        throw new CmisRuntimeException("Repository sent invalid data! No relative path segement!");
+      }
+
+      // fetch the object and make sure it is a folder
+      CmisObject parentFolder = getSession().getObject((String) idProperty.getFirstValue());
+      if (!(parentFolder instanceof Folder)) {
+        // the repository sent an object that is not a folder...
+        throw new CmisRuntimeException("Repository sent invalid data! Object is not a folder!");
+      }
+
+      this.parents.add((Folder) parentFolder);
+
+      String folderPath = ((String) pathProperty.getFirstValue());
+      this.paths.add(folderPath + (folderPath.endsWith("/") ? "" : "/")
+          + p.getRelativePathSegment());
+    }
+
+    return this.parents;
   }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.api.FileableCmisObject#getPaths()
+   */
   public List<String> getPaths() {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    if (this.paths != null) {
+      return this.paths;
+    }
+
+    getParents(); // fills the paths list too
+
+    return this.paths;
   }
 
   /*
@@ -90,13 +168,47 @@
     return null;
   }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * org.apache.opencmis.client.api.FileableCmisObject#addToFolder(org.apache.opencmis.client.api
+   * .Folder, boolean)
+   */
   public void addToFolder(Folder folder, boolean allVersions) {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    String objectId = getObjectId();
+
+    if (folder == null) {
+      throw new IllegalArgumentException("Folder must be set!");
+    }
+
+    if (folder.getId() == null) {
+      throw new IllegalArgumentException("Folder must contain an object id!");
+    }
+
+    getProvider().getMultiFilingService().addObjectToFolder(getRepositoryId(), objectId,
+        folder.getId(), allVersions, null);
   }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see
+   * org.apache.opencmis.client.api.FileableCmisObject#removeFromFolder(org.apache.opencmis.client
+   * .api.Folder)
+   */
   public void removeFromFolder(Folder folder) {
-    // TODO Auto-generated method stub
-    throw new CmisRuntimeException("not implemented");
+    String objectId = getObjectId();
+
+    if (folder == null) {
+      throw new IllegalArgumentException("Folder must be set!");
+    }
+
+    if (folder.getId() == null) {
+      throw new IllegalArgumentException("Folder must contain an object id!");
+    }
+
+    getProvider().getMultiFilingService().removeObjectFromFolder(getRepositoryId(), objectId,
+        folder.getId(), null);
   }
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentDocumentImpl.java
Tue Mar  2 12:35:10 2010
@@ -27,6 +27,7 @@
 import org.apache.opencmis.client.api.Property;
 import org.apache.opencmis.client.api.Rendition;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
+import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.enums.VersioningState;
 import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.opencmis.commons.provider.ObjectData;
@@ -41,98 +42,108 @@
     initialize(session, objectType, objectData);
   }
 
-  public void cancelCheckOut() {
-    throw new CmisRuntimeException("not implemented");
-  }
+  // properties
 
-  public void checkIn(boolean major, List<Property<?>> properties, ContentStream
contentStream,
-      String checkinComment, List<Policy> policies, List<Ace> addACEs, List<Ace>
removeACEs) {
-    throw new CmisRuntimeException("not implemented");
+  public String getCheckinComment() {
+    return getPropertyValue(PropertyIds.CMIS_CHECKIN_COMMENT);
+  }
 
+  public String getVersionLabel() {
+    return getPropertyValue(PropertyIds.CMIS_VERSION_LABEL);
   }
 
-  public boolean checkOut() {
-    throw new CmisRuntimeException("not implemented");
+  public String getVersionSeriesId() {
+    return getPropertyValue(PropertyIds.CMIS_VERSION_SERIES_ID);
   }
 
-  public Document copy(List<Property<?>> properties, VersioningState versioningState,
-      List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
-    throw new CmisRuntimeException("not implemented");
+  public String getVersionSeriesCheckedOutId() {
+    return getPropertyValue(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_ID);
   }
 
-  public void deleteAllVersions() {
-    throw new CmisRuntimeException("not implemented");
+  public String getVersionSeriesCheckedOutBy() {
+    return getPropertyValue(PropertyIds.CMIS_VERSION_SERIES_CHECKED_OUT_BY);
   }
 
-  public void deleteContentStream() {
-    throw new CmisRuntimeException("not implemented");
+  public Boolean isImmutable() {
+    return getPropertyValue(PropertyIds.CMIS_IS_IMMUTABLE);
   }
 
-  public List<Document> getAllVersions() {
-    throw new CmisRuntimeException("not implemented");
+  public Boolean isLatestMajorVersion() {
+    return getPropertyValue(PropertyIds.CMIS_IS_LATEST_MAJOR_VERSION);
   }
 
-  public String getCheckinComment() {
-    throw new CmisRuntimeException("not implemented");
+  public Boolean isLatestVersion() {
+    return getPropertyValue(PropertyIds.CMIS_IS_LATEST_VERSION);
   }
 
-  public ContentStream getContentStream() {
-    throw new CmisRuntimeException("not implemented");
+  public Boolean isMajorVersion() {
+    return getPropertyValue(PropertyIds.CMIS_IS_MAJOR_VERSION);
   }
 
-  public Document getObjectOfLatestVersion(boolean major) {
-    throw new CmisRuntimeException("not implemented");
+  public Boolean isVersionSeriesCheckedOut() {
+    return getPropertyValue(PropertyIds.CMIS_IS_VERSION_SERIES_CHECKED_OUT);
   }
 
-  public List<Property<?>> getPropertiesOfLatestVersion(boolean major) {
+  // operations
+
+  public Document copy(List<Property<?>> properties, VersioningState versioningState,
+      List<Policy> policies, List<Ace> addACEs, List<Ace> removeACEs) {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public List<Property<?>> getPropertiesOfLatestVersion(boolean major, String
filter) {
-    throw new CmisRuntimeException("not implemented");
+  public void deleteAllVersions() {
+    delete(true);
   }
 
-  public List<Rendition> getRenditions() {
+  // versioning
+
+  public boolean checkOut() {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public String getVersionLabel() {
+  public void cancelCheckOut() {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public String getVersionSeries() {
+  public void checkIn(boolean major, List<Property<?>> properties, ContentStream
contentStream,
+      String checkinComment, List<Policy> policies, List<Ace> addACEs, List<Ace>
removeACEs) {
     throw new CmisRuntimeException("not implemented");
+
   }
 
-  public String getVersionSeriesCheckedOut() {
+  public List<Document> getAllVersions() {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public String getVersionSeriesCheckedOutBy() {
+  public Document getObjectOfLatestVersion(boolean major) {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public boolean isImmutable() {
+  public List<Property<?>> getPropertiesOfLatestVersion(boolean major) {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public boolean isLatestMajorVersion() {
+  public List<Property<?>> getPropertiesOfLatestVersion(boolean major, String
filter) {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public boolean isLatestVersion() {
+  // content operations
+
+  public ContentStream getContentStream() {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public boolean isMajorVersion() {
+  public void setContentStream(boolean overwrite, ContentStream contentStream) {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public boolean isVersionSeriesCheckedOut() {
+  public void deleteContentStream() {
     throw new CmisRuntimeException("not implemented");
   }
 
-  public void setContentStream(boolean overwrite, ContentStream contentStream) {
+  // renditions
+
+  public List<Rendition> getRenditions() {
     throw new CmisRuntimeException("not implemented");
   }
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentPolicyImpl.java
Tue Mar  2 12:35:10 2010
@@ -20,7 +20,7 @@
 
 import org.apache.opencmis.client.api.Policy;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
-import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.provider.ObjectData;
 
 public class PersistentPolicyImpl extends AbstractPersistentFilableCmisObject implements
Policy {
@@ -34,7 +34,7 @@
   }
 
   public String getPolicyText() {
-    throw new CmisRuntimeException("not implemented");
+    return getPropertyValue(PropertyIds.CMIS_POLICY_TEXT);
   }
 
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-client-impl/src/main/java/org/apache/opencmis/client/runtime/PersistentRelationshipImpl.java
Tue Mar  2 12:35:10 2010
@@ -21,12 +21,15 @@
 import org.apache.opencmis.client.api.CmisObject;
 import org.apache.opencmis.client.api.Relationship;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
-import org.apache.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.opencmis.commons.PropertyIds;
 import org.apache.opencmis.commons.provider.ObjectData;
 
 public class PersistentRelationshipImpl extends AbstractPersistentCmisObject implements
     Relationship {
 
+  private CmisObject source;
+  private CmisObject target;
+
   /**
    * Constructor.
    */
@@ -35,13 +38,41 @@
     initialize(session, objectType, objectData);
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.opencmis.client.api.Relationship#getSource()
+   */
   public CmisObject getSource() {
-    throw new CmisRuntimeException("not implemented");
+    if (this.source != null) {
+      return this.source;
+    }
+
+    String sourceId = getPropertyValue(PropertyIds.CMIS_SOURCE_ID);
+    if (sourceId == null) {
+      return null;
+    }
+
+    this.source = getSession().getObject(sourceId);
 
+    return this.source;
   }
 
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.opencmis.client.api.Relationship#getTarget()
+   */
   public CmisObject getTarget() {
-    throw new CmisRuntimeException("not implemented");
+    if (this.target != null) {
+      return this.target;
+    }
+
+    String targetId = getPropertyValue(PropertyIds.CMIS_TARGET_ID);
+    if (targetId == null) {
+      return null;
+    }
+
+    this.target = getSession().getObject(targetId);
 
+    return this.target;
   }
 }

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/HttpUtils.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/HttpUtils.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/HttpUtils.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/main/java/org/apache/opencmis/client/provider/spi/atompub/HttpUtils.java
Tue Mar  2 12:35:10 2010
@@ -165,7 +165,6 @@
     private String fResponseMessage;
     private Map<String, List<String>> fHeaders;
     private InputStream fStream;
-    private InputStream fErrorStream;
     private String fErrorContent;
 
     public Response(int responseCode, String responseMessage, Map<String, List<String>>
headers,
@@ -173,7 +172,6 @@
       fResponseCode = responseCode;
       fResponseMessage = responseMessage;
       fStream = stream;
-      fErrorStream = errorStream;
 
       fHeaders = new HashMap<String, List<String>>();
       if (headers != null) {

Modified: incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/test/java/org/apache/opencmis/client/provider/framework/AbstractSimpleReadOnlyTests.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/test/java/org/apache/opencmis/client/provider/framework/AbstractSimpleReadOnlyTests.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/test/java/org/apache/opencmis/client/provider/framework/AbstractSimpleReadOnlyTests.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-client/opencmis-provider-impl/src/test/java/org/apache/opencmis/client/provider/framework/AbstractSimpleReadOnlyTests.java
Tue Mar  2 12:35:10 2010
@@ -127,6 +127,8 @@
     assertNotNull(types.hasMoreItems());
     assertNotNull(types.getList());
     assertFalse(types.getList().isEmpty());
+    assertTrue(types.getList().size() >= 2);
+    assertTrue(types.getList().size() <= 4);
 
     getProvider().clearAllCaches();
 

Modified: incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/sample/AbstractSampleIT.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/sample/AbstractSampleIT.java?rev=918000&r1=917999&r2=918000&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/sample/AbstractSampleIT.java
(original)
+++ incubator/chemistry/trunk/opencmis/opencmis-test/opencmis-test-fit/src/test/java/org/apache/opencmis/fit/sample/AbstractSampleIT.java
Tue Mar  2 12:35:10 2010
@@ -24,9 +24,13 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
+
 import org.apache.opencmis.client.api.Session;
 import org.apache.opencmis.client.api.objecttype.ObjectType;
 import org.apache.opencmis.client.api.repository.RepositoryInfo;
+import org.apache.opencmis.client.api.util.Container;
+import org.apache.opencmis.client.api.util.PagingList;
 import org.apache.opencmis.commons.enums.BaseObjectTypeIds;
 import org.apache.opencmis.fit.SessionFactory;
 import org.junit.Before;
@@ -75,6 +79,11 @@
     RepositoryInfo ri = getSession().getRepositoryInfo();
     assertNotNull(ri);
     assertEquals(SessionFactory.getRepositoryId(), ri.getId());
+    assertNotNull(ri.getName());
+    assertNotNull(ri.getRootFolderId());
+    assertNotNull(ri.getCmisVersionSupported());
+    assertNotNull(ri.getCapabilities());
+    assertNotNull(ri.getAclCapabilities());
   }
 
   /**
@@ -82,27 +91,84 @@
    */
   @Test
   public void testTypes() {
-    String documnetBaseId = "cmis:document";
+    String documentBaseId = "cmis:document";
     String folderBaseId = "cmis:folder";
 
-    ObjectType documentType = getSession().getTypeDefinition(documnetBaseId);
-    assertNotNull(documentType);
-    assertEquals(documnetBaseId, documentType.getId());
-    assertEquals(BaseObjectTypeIds.CMIS_DOCUMENT, documentType.getBaseTypeId());
-    assertTrue(documentType.isBaseType());
-    assertNull(documentType.getBaseType());
-    assertNull(documentType.getParent());
-    assertNotNull(documentType.getPropertyDefintions());
-    assertFalse(documentType.getPropertyDefintions().isEmpty());
+    // check document type definition
+    ObjectType documentType = getSession().getTypeDefinition(documentBaseId);
+    checkBaseType(documentBaseId, BaseObjectTypeIds.CMIS_DOCUMENT, documentType);
 
+    // check folder type definition
     ObjectType folderType = getSession().getTypeDefinition(folderBaseId);
-    assertNotNull(folderType);
-    assertEquals(folderBaseId, folderType.getId());
-    assertEquals(BaseObjectTypeIds.CMIS_FOLDER, folderType.getBaseTypeId());
-    assertTrue(folderType.isBaseType());
-    assertNull(folderType.getBaseType());
-    assertNull(folderType.getParent());
-    assertNotNull(folderType.getPropertyDefintions());
-    assertFalse(folderType.getPropertyDefintions().isEmpty());
+    checkBaseType(folderBaseId, BaseObjectTypeIds.CMIS_FOLDER, folderType);
+
+    // get base types via getTypesChildren
+    PagingList<ObjectType> baseTypes = getSession().getTypeChildren(null, true, 10);
+    assertNotNull(baseTypes);
+
+    List<ObjectType> baseTypePage = baseTypes.get(0);
+    assertNotNull(baseTypePage);
+    assertTrue(baseTypePage.size() >= 2);
+    assertTrue(baseTypePage.size() <= 4);
+
+    assertEquals(1, baseTypes.size());
+    assertEquals(baseTypePage.size(), baseTypes.getNumItems());
+
+    boolean hasDocumentBaseType = false;
+    boolean hasFolderBaseType = false;
+    for (ObjectType ot : baseTypePage) {
+      checkBaseType(null, null, ot);
+
+      if (ot.getId().equals(documentBaseId)) {
+        hasDocumentBaseType = true;
+      }
+
+      if (ot.getId().equals(folderBaseId)) {
+        hasFolderBaseType = true;
+      }
+    }
+
+    assertTrue(hasDocumentBaseType);
+    assertTrue(hasFolderBaseType);
+
+    // get base types via getTypeDescendants
+    List<Container<ObjectType>> baseTypeDesc = getSession().getTypeDescendants(null,
-1, true);
+    assertNotNull(baseTypeDesc);
+
+    hasDocumentBaseType = false;
+    hasFolderBaseType = false;
+    for (Container<ObjectType> cot : baseTypeDesc) {
+      assertNotNull(cot);
+      //checkBaseType(null, null, cot.getItem());
+
+      if (cot.getItem().getId().equals(documentBaseId)) {
+        hasDocumentBaseType = true;
+      }
+
+      if (cot.getItem().getId().equals(folderBaseId)) {
+        hasFolderBaseType = true;
+      }
+    }
+
+    assertTrue(hasDocumentBaseType);
+    assertTrue(hasFolderBaseType);
+  }
+
+  /**
+   * Checks a base type.
+   */
+  private void checkBaseType(String id, BaseObjectTypeIds baseType, ObjectType objectType)
{
+    assertNotNull(objectType);
+    if (id != null) {
+      assertEquals(id, objectType.getId());
+    }
+    if (baseType != null) {
+      assertEquals(baseType, objectType.getBaseTypeId());
+    }
+    assertTrue(objectType.isBaseType());
+    assertNull(objectType.getBaseType());
+    assertNull(objectType.getParent());
+    assertNotNull(objectType.getPropertyDefintions());
+    assertFalse(objectType.getPropertyDefintions().isEmpty());
   }
 }



Mime
View raw message