chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcaru...@apache.org
Subject svn commit: r934889 [3/5] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src: main/java/org/apache/chemistry/opencmis/client/ main/java/org/apache/chemistry/opencmis/client/runtime/ main/java/org/apach...
Date Fri, 16 Apr 2010 14:07:12 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentRelationshipImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentRelationshipImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentRelationshipImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentRelationshipImpl.java Fri Apr 16 14:07:11 2010
@@ -25,73 +25,70 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.api.ObjectData;
 
-public class PersistentRelationshipImpl extends AbstractPersistentCmisObject implements
-    Relationship {
+public class PersistentRelationshipImpl extends AbstractPersistentCmisObject implements Relationship {
 
-  /**
-   * Constructor.
-   */
-  public PersistentRelationshipImpl(PersistentSessionImpl session, ObjectType objectType,
-      ObjectData objectData, OperationContext context) {
-    initialize(session, objectType, objectData, context);
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.Relationship#getSource()
-   */
-  public CmisObject getSource() {
-    return getSource(getSession().getDefaultContext());
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.Relationship#getSource()
-   */
-  public CmisObject getSource(OperationContext context) {
-    readLock();
-    try {
-      String sourceId = getPropertyValue(PropertyIds.SOURCE_ID);
-      if (sourceId == null) {
-        return null;
-      }
-
-      return getSession().getObject(getSession().createObjectId(sourceId), context);
-    }
-    finally {
-      readUnlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.Relationship#getTarget()
-   */
-  public CmisObject getTarget() {
-    return getTarget(getSession().getDefaultContext());
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.api.Relationship#getTarget()
-   */
-  public CmisObject getTarget(OperationContext context) {
-    readLock();
-    try {
-      String targetId = getPropertyValue(PropertyIds.TARGET_ID);
-      if (targetId == null) {
-        return null;
-      }
-
-      return getSession().getObject(getSession().createObjectId(targetId), context);
-    }
-    finally {
-      readUnlock();
-    }
-  }
+	/**
+	 * Constructor.
+	 */
+	public PersistentRelationshipImpl(PersistentSessionImpl session, ObjectType objectType, ObjectData objectData,
+			OperationContext context) {
+		initialize(session, objectType, objectData, context);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Relationship#getSource()
+	 */
+	public CmisObject getSource() {
+		return getSource(getSession().getDefaultContext());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Relationship#getSource()
+	 */
+	public CmisObject getSource(OperationContext context) {
+		readLock();
+		try {
+			String sourceId = getPropertyValue(PropertyIds.SOURCE_ID);
+			if (sourceId == null) {
+				return null;
+			}
+
+			return getSession().getObject(getSession().createObjectId(sourceId), context);
+		} finally {
+			readUnlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Relationship#getTarget()
+	 */
+	public CmisObject getTarget() {
+		return getTarget(getSession().getDefaultContext());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Relationship#getTarget()
+	 */
+	public CmisObject getTarget(OperationContext context) {
+		readLock();
+		try {
+			String targetId = getPropertyValue(PropertyIds.TARGET_ID);
+			if (targetId == null) {
+				return null;
+			}
+
+			return getSession().getObject(getSession().createObjectId(targetId), context);
+		} finally {
+			readUnlock();
+		}
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/PersistentSessionImpl.java Fri Apr 16 14:07:11 2010
@@ -73,780 +73,776 @@ import org.apache.commons.logging.LogFac
  */
 public class PersistentSessionImpl implements Session, Serializable {
 
-  private static final OperationContext DEFAULT_CONTEXT = new OperationContextImpl(null, false,
-      true, false, IncludeRelationships.NONE, null, true, null, true);
+	private static final OperationContext DEFAULT_CONTEXT = new OperationContextImpl(null, false, true, false,
+			IncludeRelationships.NONE, null, true, null, true);
 
-  private static final Set<Updatability> CREATE_UPDATABILITY = new HashSet<Updatability>();
-  static {
-    CREATE_UPDATABILITY.add(Updatability.ONCREATE);
-    CREATE_UPDATABILITY.add(Updatability.READWRITE);
-  }
-
-  private static Log log = LogFactory.getLog(PersistentSessionImpl.class);
-
-  private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
-
-  /*
-   * default session context (serializable)
-   */
-  private OperationContext context = DEFAULT_CONTEXT;
-
-  /*
-   * session parameter (serializable)
-   */
-  private Map<String, String> parameters = null;
-
-  /*
-   * CMIS provider (serializable)
-   */
-  private CmisBinding binding = null;
-
-  /*
-   * Session Locale, determined from session parameter (serializable)
-   */
-  private Locale locale = null;
-
-  /*
-   * Object cache (serializable)
-   */
-  private Cache cache = null;
-
-  /*
-   * Lazy loaded repository info. Will be invalid after clear(). Access by getter always.
-   * (serializable)
-   */
-  private RepositoryInfo repositoryInfo;
-
-  /*
-   * helper factory (non serializable)
-   */
-  private final ObjectFactory objectFactory = PersistentObjectFactoryImpl.newInstance(this);
-
-  /**
-   * required for serialization
-   */
-  private static final long serialVersionUID = -4287481628831198383L;
-
-  /**
-   * Constructor.
-   */
-  public PersistentSessionImpl(Map<String, String> parameters) {
-    this.parameters = parameters;
-    PersistentSessionImpl.log.info("Session Parameters: " + parameters);
-
-    this.locale = this.determineLocale(parameters);
-    PersistentSessionImpl.log.info("Session Locale: " + this.locale.toString());
-
-    int cacheSize = this.determineCacheSize(parameters);
-
-    if (cacheSize == -1) {
-      this.cache = CacheImpl.newInstance();
-    }
-    else {
-      this.cache = CacheImpl.newInstance(cacheSize);
-    }
-    PersistentSessionImpl.log.info("Session Cache Size: " + this.cache.getCacheSize());
-  }
-
-  private int determineCacheSize(Map<String, String> parameters) {
-    int size = -1;
-
-    return size;
-  }
-
-  private String determineRepositoryId(Map<String, String> parameters) {
-    String repositoryId = parameters.get(SessionParameter.REPOSITORY_ID);
-    // if null then the provider will return a repository id (lazy)
-    return repositoryId;
-  }
-
-  private Locale determineLocale(Map<String, String> parameters) {
-    Locale locale = null;
-
-    String language = parameters.get(SessionParameter.LOCALE_ISO639_LANGUAGE);
-    String country = parameters.get(SessionParameter.LOCALE_ISO3166_COUNTRY);
-    String variant = parameters.get(SessionParameter.LOCALE_VARIANT);
-
-    if (variant != null) {
-      // all 3 parameter must not be null and valid
-      locale = new Locale(language, country, variant);
-    }
-    else {
-      if (country != null) {
-        // 2 parameter must not be null and valid
-        locale = new Locale(language, country);
-      }
-      else {
-        if (language != null) {
-          // 1 parameter must not be null and valid
-          locale = new Locale(language);
-        }
-        else {
-          locale = Locale.getDefault();
-        }
-      }
-    }
-
-    return locale;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#clear()
-   */
-  public void clear() {
-    fLock.writeLock().lock();
-    try {
-      int cacheSize = this.determineCacheSize(this.parameters);
-      if (cacheSize == -1) {
-        this.cache = CacheImpl.newInstance();
-      }
-      else {
-        this.cache = CacheImpl.newInstance(cacheSize);
-      }
-      PersistentSessionImpl.log.info("Session Cache Size: " + this.cache.getCacheSize());
-
-      /*
-       * clear provider cache
-       */
-      getBinding().clearAllCaches();
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  public void save() {
-      // nop
-  }
-
-  public void cancel() {
-      throw new UnsupportedOperationException("cancel");
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getObjectFactory()
-   */
-  public ObjectFactory getObjectFactory() {
-    return this.objectFactory;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getCheckedOutDocs(int)
-   */
-  public PagingList<Document> getCheckedOutDocs(int itemsPerPage) {
-    return getCheckedOutDocs(getDefaultContext(), itemsPerPage);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @seeorg.apache.opencmis.client.api.Session#getCheckedOutDocs(org.apache.opencmis.client.api.
-   * OperationContext, int)
-   */
-  public PagingList<Document> getCheckedOutDocs(OperationContext context, final int itemsPerPage) {
-    if (itemsPerPage < 1) {
-      throw new IllegalArgumentException("itemsPerPage must be > 0!");
-    }
-
-    final NavigationService nagivationService = getBinding().getNavigationService();
-    final ObjectFactory objectFactory = getObjectFactory();
-    final OperationContext ctxt = new OperationContextImpl(context);
-
-    return new AbstractPagingList<Document>() {
-
-      @Override
-      protected FetchResult fetchPage(int pageNumber) {
-        int skipCount = pageNumber * getMaxItemsPerPage();
-
-        // get all checked out documents
-        ObjectList checkedOutDocs = nagivationService.getCheckedOutDocs(getRepositoryId(), null,
-            ctxt.getFilterString(), ctxt.getOrderBy(), ctxt.isIncludeAllowableActions(), ctxt
-                .getIncludeRelationships(), ctxt.getRenditionFilterString(), BigInteger
-                .valueOf(getMaxItemsPerPage()), BigInteger.valueOf(skipCount), null);
-
-        // convert objects
-        List<Document> page = new ArrayList<Document>();
-        if (checkedOutDocs.getObjects() != null) {
-          for (ObjectData objectData : checkedOutDocs.getObjects()) {
-            CmisObject doc = objectFactory.convertObject(objectData, ctxt);
-            if (!(doc instanceof Document)) {
-              // should not happen...
-              continue;
-            }
-
-            page.add((Document) doc);
-          }
-        }
-
-        return new FetchResult(page, checkedOutDocs.getNumItems(), checkedOutDocs.hasMoreItems());
-      }
-
-      @Override
-      public int getMaxItemsPerPage() {
-        return itemsPerPage;
-      }
-    };
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getContentChanges(java.lang.String, int)
-   */
-  public PagingList<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getDefaultContext()
-   */
-  public OperationContext getDefaultContext() {
-    fLock.readLock().lock();
-    try {
-      return this.context;
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @seeorg.apache.opencmis.client.api.Session#setDefaultContext(org.apache.opencmis.client.api.
-   * OperationContext)
-   */
-  public void setDefaultContext(OperationContext context) {
-    fLock.writeLock().lock();
-    try {
-      this.context = (context == null ? DEFAULT_CONTEXT : context);
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#createOperationContext(java.util.Set, boolean,
-   * boolean, boolean, org.apache.opencmis.commons.enums.IncludeRelationships, java.util.Set,
-   * boolean, java.lang.String, boolean)
-   */
-  public OperationContext createOperationContext(Set<String> filter, boolean includeAcls,
-      boolean includeAllowableActions, boolean includePolicies,
-      IncludeRelationships includeRelationships, Set<String> renditionFilter,
-      boolean includePathSegments, String orderBy, boolean cacheEnabled) {
-    return new OperationContextImpl(filter, includeAcls, includeAllowableActions, includePolicies,
-        includeRelationships, renditionFilter, includePathSegments, orderBy, cacheEnabled);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#createObjectId(java.lang.String)
-   */
-  public ObjectId createObjectId(String id) {
-    return new ObjectIdImpl(id);
-  }
-
-  public Locale getLocale() {
-    return this.locale;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getObject(java.lang.String)
-   */
-  public CmisObject getObject(ObjectId objectId) {
-    return getObject(objectId, getDefaultContext());
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getObject(java.lang.String,
-   * org.apache.opencmis.client.api.OperationContext)
-   */
-  public CmisObject getObject(ObjectId objectId, OperationContext context) {
-    if ((objectId == null) || (objectId.getId() == null)) {
-      throw new IllegalArgumentException("Object Id must be set!");
-    }
-    if (context == null) {
-      throw new IllegalArgumentException("Operation context must be set!");
-    }
-
-    CmisObject result = null;
-
-    // ask the cache first
-    if (context.isCacheEnabled()) {
-      result = this.cache.getById(objectId.getId(), context.getCacheKey());
-      if (result != null) {
-        return result;
-      }
-    }
-
-    // get the object
-    ObjectData objectData = this.binding.getObjectService().getObject(getRepositoryId(),
-        objectId.getId(), context.getFilterString(), context.isIncludeAllowableActions(),
-        context.getIncludeRelationships(), context.getRenditionFilterString(),
-        context.isIncludePolicies(), context.isIncludeAcls(), null);
-
-    result = getObjectFactory().convertObject(objectData, context);
-
-    // put into cache
-    if (context.isCacheEnabled()) {
-      this.cache.put(result, context.getCacheKey());
-    }
-
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getObjectByPath(java.lang.String)
-   */
-  public CmisObject getObjectByPath(String path) {
-    return getObjectByPath(path, getDefaultContext());
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getObjectByPath(java.lang.String,
-   * org.apache.opencmis.client.api.OperationContext)
-   */
-  public CmisObject getObjectByPath(String path, OperationContext context) {
-    if (path == null) {
-      throw new IllegalArgumentException("Path must be set!");
-    }
-    if (context == null) {
-      throw new IllegalArgumentException("Operation context must be set!");
-    }
-
-    CmisObject result = null;
-
-    // ask the cache first
-    if (context.isCacheEnabled()) {
-      result = this.cache.getByPath(path, context.getCacheKey());
-      if (result != null) {
-        return result;
-      }
-    }
-
-    // get the object
-    ObjectData objectData = this.binding.getObjectService().getObjectByPath(getRepositoryId(),
-        path, context.getFilterString(), context.isIncludeAllowableActions(),
-        context.getIncludeRelationships(), context.getRenditionFilterString(),
-        context.isIncludePolicies(), context.isIncludeAcls(), null);
-
-    result = getObjectFactory().convertObject(objectData, context);
-
-    // put into cache
-    if (context.isCacheEnabled()) {
-      this.cache.putPath(path, result, context.getCacheKey());
-    }
-
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getRepositoryInfo()
-   */
-  public RepositoryInfo getRepositoryInfo() {
-    fLock.readLock().lock();
-    try {
-      return this.repositoryInfo;
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getRootFolder()
-   */
-  public Folder getRootFolder() {
-    return getRootFolder(getDefaultContext());
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @seeorg.apache.opencmis.client.api.Session#getRootFolder(org.apache.opencmis.client.api.
-   * OperationContext)
-   */
-  public Folder getRootFolder(OperationContext context) {
-    String rootFolderId = getRepositoryInfo().getRootFolderId();
-
-    CmisObject rootFolder = getObject(createObjectId(rootFolderId), context);
-    if (!(rootFolder instanceof Folder)) {
-      throw new CmisRuntimeException("Root folder object is not a folder!");
-    }
-
-    return (Folder) rootFolder;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getTypeChildren(java.lang.String, boolean, int)
-   */
-  public PagingList<ObjectType> getTypeChildren(final String typeId,
-      final boolean includePropertyDefinitions, final int itemsPerPage) {
-    if (itemsPerPage < 1) {
-      throw new IllegalArgumentException("itemsPerPage must be > 0!");
-    }
-
-    final String repositoryId = getRepositoryId();
-    final RepositoryService repositoryService = getBinding().getRepositoryService();
-
-    // set up PagingList object
-    return new AbstractPagingList<ObjectType>() {
-
-      @Override
-      protected FetchResult fetchPage(int pageNumber) {
-        int skipCount = pageNumber * getMaxItemsPerPage();
-
-        // fetch the data
-        TypeDefinitionList tdl = repositoryService.getTypeChildren(repositoryId, typeId,
-            includePropertyDefinitions, BigInteger.valueOf(getMaxItemsPerPage()), BigInteger
-                .valueOf(skipCount), null);
-
-        // convert type definitions
-        List<ObjectType> page = new ArrayList<ObjectType>(tdl.getList().size());
-        for (TypeDefinition typeDefinition : tdl.getList()) {
-          page.add(objectFactory.convertTypeDefinition(typeDefinition));
-        }
-
-        return new FetchResult(page, tdl.getNumItems(), tdl.hasMoreItems());
-      }
-
-      @Override
-      public int getMaxItemsPerPage() {
-        return itemsPerPage;
-      }
-    };
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getTypeDefinition(java.lang.String)
-   */
-  public ObjectType getTypeDefinition(String typeId) {
-    TypeDefinition typeDefinition = getBinding().getRepositoryService().getTypeDefinition(
-        getRepositoryId(), typeId, null);
-    return objectFactory.convertTypeDefinition(typeDefinition);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getTypeDescendants(java.lang.String, int, boolean)
-   */
-  public List<Tree<ObjectType>> getTypeDescendants(String typeId, int depth,
-      boolean includePropertyDefinitions) {
-    List<TypeDefinitionContainer> descendants = getBinding().getRepositoryService()
-        .getTypeDescendants(getRepositoryId(), typeId, BigInteger.valueOf(depth),
-            includePropertyDefinitions, null);
-
-    return convertTypeDescendants(descendants);
-  }
-
-  /**
-   * Converts provider <code>TypeDefinitionContainer</code> to API <code>Container</code>.
-   */
-  private List<Tree<ObjectType>> convertTypeDescendants(
-      List<TypeDefinitionContainer> descendantsList) {
-    List<Tree<ObjectType>> result = new ArrayList<Tree<ObjectType>>();
-
-    for (TypeDefinitionContainer container : descendantsList) {
-      ObjectType objectType = objectFactory.convertTypeDefinition(container.getTypeDefinition());
-      List<Tree<ObjectType>> children = convertTypeDescendants(container.getChildren());
-
-      result.add(new ContainerImpl<ObjectType>(objectType, children));
-    }
-
-    return result;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#query(java.lang.String, boolean, int)
-   */
-  public PagingList<QueryResult> query(final String statement, final boolean searchAllVersions,
-      final int itemsPerPage) {
-    return query(statement, searchAllVersions, getDefaultContext(), itemsPerPage);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#query(java.lang.String, boolean,
-   * org.apache.opencmis.client.api.OperationContext, int)
-   */
-  public PagingList<QueryResult> query(final String statement, final boolean searchAllVersions,
-      OperationContext context, final int itemsPerPage) {
-
-    final DiscoveryService discoveryService = getBinding().getDiscoveryService();
-    final ObjectFactory of = getObjectFactory();
-    final OperationContext ctxt = new OperationContextImpl(context);
-
-    // set up PagingList object
-    return new AbstractPagingList<QueryResult>() {
-
-      @Override
-      protected FetchResult fetchPage(int pageNumber) {
-        int skipCount = pageNumber * getMaxItemsPerPage();
-
-        // fetch the data
-        ObjectList resultList = discoveryService.query(getRepositoryId(), statement,
-            searchAllVersions, ctxt.isIncludeAllowableActions(), ctxt.getIncludeRelationships(),
-            ctxt.getRenditionFilterString(), BigInteger.valueOf(getMaxItemsPerPage()), BigInteger
-                .valueOf(skipCount), null);
-
-        // convert type definitions
-        List<QueryResult> page = new ArrayList<QueryResult>();
-        if (resultList.getObjects() != null) {
-          for (ObjectData objectData : resultList.getObjects()) {
-            if (objectData == null) {
-              continue;
-            }
-
-            page.add(of.convertQueryResult(objectData));
-          }
-        }
-
-        return new FetchResult(page, resultList.getNumItems(), resultList.hasMoreItems());
-      }
-
-      @Override
-      public int getMaxItemsPerPage() {
-        return itemsPerPage;
-      }
-    };
-  }
-
-  public String setExtensionContext(String context) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
-  public ExtensionHandler setExtensionHandler(String context, ExtensionHandler extensionHandler) {
-    throw new CmisRuntimeException("not implemented");
-  }
-
-  /**
-   * Connect session object to the provider. This is the very first call after a session is created.
-   * <p>
-   * In dependency of the parameter set an {@code AtomPub}, a {@code WebService} or an {@code
-   * InMemory} provider is selected.
-   */
-  public void connect() {
-    fLock.writeLock().lock();
-    try {
-      this.binding = CmisBindingHelper.createProvider(this.parameters);
-
-      /* get initial repository id from session parameter */
-      String repositoryId = this.determineRepositoryId(this.parameters);
-      if (repositoryId == null) {
-        throw new IllegalStateException("Repository Id is not set!");
-      }
-
-      repositoryInfo = getBinding().getRepositoryService().getRepositoryInfo(
-          repositoryId, null);
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#getBinding()
-   */
-  public CmisBinding getBinding() {
-    fLock.readLock().lock();
-    try {
-      return this.binding;
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  public Cache getCache() {
-    fLock.readLock().lock();
-    try {
-      return this.cache;
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /**
-   * Returns the repository id.
-   */
-  public String getRepositoryId() {
-    return getRepositoryInfo().getId();
-  }
-
-  // creates
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#createDocument(java.util.Map,
-   * org.apache.opencmis.client.api.ObjectId, org.apache.opencmis.client.api.ContentStream,
-   * org.apache.opencmis.commons.enums.VersioningState, java.util.List, java.util.List,
-   * java.util.List)
-   */
-  public ObjectId createDocument(Map<String, ?> properties, ObjectId folderId,
-      ContentStream contentStream, VersioningState versioningState, List<Policy> policies,
-      List<Ace> addAces, List<Ace> removeAces) {
-    if ((folderId != null) && (folderId.getId() == null)) {
-      throw new IllegalArgumentException("Folder Id must be set!");
-    }
-
-    String newId = getBinding().getObjectService().createDocument(getRepositoryId(),
-        objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
-        (folderId == null ? null : folderId.getId()),
-        objectFactory.convertContentStream(contentStream), versioningState,
-        objectFactory.convertPolicies(policies), objectFactory.convertAces(addAces),
-        objectFactory.convertAces(removeAces), null);
-
-    if (newId == null) {
-      return null;
-    }
-
-    return createObjectId(newId);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.Session#createDocumentFromSource(org.apache.opencmis.client.
-   * api.ObjectId, java.util.Map, org.apache.opencmis.client.api.ObjectId,
-   * org.apache.opencmis.commons.enums.VersioningState, java.util.List, java.util.List,
-   * java.util.List)
-   */
-  public ObjectId createDocumentFromSource(ObjectId source, Map<String, ?> properties,
-      ObjectId folderId, VersioningState versioningState, List<Policy> policies, List<Ace> addAces,
-      List<Ace> removeAces) {
-    if ((folderId != null) && (folderId.getId() == null)) {
-      throw new IllegalArgumentException("Folder Id must be set!");
-    }
-
-    // get the type of the source document
-    ObjectType type = null;
-    if (source instanceof CmisObject) {
-      type = ((CmisObject) source).getBaseType();
-    }
-    else {
-      CmisObject sourceObj = getObject(source);
-      type = sourceObj.getType();
-    }
-
-    if (type.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
-      throw new IllegalArgumentException("Source object must be a document!");
-    }
-
-    String newId = getBinding().getObjectService().createDocumentFromSource(getRepositoryId(),
-        source.getId(), objectFactory.convertProperties(properties, type, CREATE_UPDATABILITY),
-        (folderId == null ? null : folderId.getId()), versioningState,
-        objectFactory.convertPolicies(policies), objectFactory.convertAces(addAces),
-        objectFactory.convertAces(removeAces), null);
-
-    if (newId == null) {
-      return null;
-    }
-
-    return createObjectId(newId);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#createFolder(java.util.Map,
-   * org.apache.opencmis.client.api.ObjectId, java.util.List, java.util.List, java.util.List)
-   */
-  public ObjectId createFolder(Map<String, ?> properties, ObjectId folderId, List<Policy> policies,
-      List<Ace> addAces, List<Ace> removeAces) {
-    if ((folderId != null) && (folderId.getId() == null)) {
-      throw new IllegalArgumentException("Folder Id must be set!");
-    }
-
-    String newId = getBinding().getObjectService().createFolder(getRepositoryId(),
-        objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
-        (folderId == null ? null : folderId.getId()), objectFactory.convertPolicies(policies),
-        objectFactory.convertAces(addAces), objectFactory.convertAces(removeAces), null);
-
-    if (newId == null) {
-      return null;
-    }
-
-    return createObjectId(newId);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#createPolicy(java.util.Map,
-   * org.apache.opencmis.client.api.ObjectId, java.util.List, java.util.List, java.util.List)
-   */
-  public ObjectId createPolicy(Map<String, ?> properties, ObjectId folderId, List<Policy> policies,
-      List<Ace> addAces, List<Ace> removeAces) {
-    if ((folderId != null) && (folderId.getId() == null)) {
-      throw new IllegalArgumentException("Folder Id must be set!");
-    }
-
-    String newId = getBinding().getObjectService().createPolicy(getRepositoryId(),
-        objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
-        (folderId == null ? null : folderId.getId()), objectFactory.convertPolicies(policies),
-        objectFactory.convertAces(addAces), objectFactory.convertAces(removeAces), null);
-
-    if (newId == null) {
-      return null;
-    }
-
-    return createObjectId(newId);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.Session#createRelationship(java.util.Map, java.util.List,
-   * java.util.List, java.util.List)
-   */
-  public ObjectId createRelationship(Map<String, ?> properties, List<Policy> policies,
-      List<Ace> addAces, List<Ace> removeAces) {
-    String newId = getBinding().getObjectService().createRelationship(getRepositoryId(),
-        objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
-        objectFactory.convertPolicies(policies), objectFactory.convertAces(addAces),
-        objectFactory.convertAces(removeAces), null);
-
-    if (newId == null) {
-      return null;
-    }
+	private static final Set<Updatability> CREATE_UPDATABILITY = new HashSet<Updatability>();
+	static {
+		CREATE_UPDATABILITY.add(Updatability.ONCREATE);
+		CREATE_UPDATABILITY.add(Updatability.READWRITE);
+	}
+
+	private static Log log = LogFactory.getLog(PersistentSessionImpl.class);
+
+	private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+
+	/*
+	 * default session context (serializable)
+	 */
+	private OperationContext context = DEFAULT_CONTEXT;
+
+	/*
+	 * session parameter (serializable)
+	 */
+	private Map<String, String> parameters = null;
+
+	/*
+	 * CMIS provider (serializable)
+	 */
+	private CmisBinding binding = null;
+
+	/*
+	 * Session Locale, determined from session parameter (serializable)
+	 */
+	private Locale locale = null;
+
+	/*
+	 * Object cache (serializable)
+	 */
+	private Cache cache = null;
+
+	/*
+	 * Lazy loaded repository info. Will be invalid after clear(). Access by
+	 * getter always. (serializable)
+	 */
+	private RepositoryInfo repositoryInfo;
+
+	/*
+	 * helper factory (non serializable)
+	 */
+	private final ObjectFactory objectFactory = PersistentObjectFactoryImpl.newInstance(this);
+
+	/**
+	 * required for serialization
+	 */
+	private static final long serialVersionUID = -4287481628831198383L;
+
+	/**
+	 * Constructor.
+	 */
+	public PersistentSessionImpl(Map<String, String> parameters) {
+		this.parameters = parameters;
+		PersistentSessionImpl.log.info("Session Parameters: " + parameters);
+
+		this.locale = this.determineLocale(parameters);
+		PersistentSessionImpl.log.info("Session Locale: " + this.locale.toString());
+
+		int cacheSize = this.determineCacheSize(parameters);
+
+		if (cacheSize == -1) {
+			this.cache = CacheImpl.newInstance();
+		} else {
+			this.cache = CacheImpl.newInstance(cacheSize);
+		}
+		PersistentSessionImpl.log.info("Session Cache Size: " + this.cache.getCacheSize());
+	}
+
+	private int determineCacheSize(Map<String, String> parameters) {
+		int size = -1;
+
+		return size;
+	}
+
+	private String determineRepositoryId(Map<String, String> parameters) {
+		String repositoryId = parameters.get(SessionParameter.REPOSITORY_ID);
+		// if null then the provider will return a repository id (lazy)
+		return repositoryId;
+	}
+
+	private Locale determineLocale(Map<String, String> parameters) {
+		Locale locale = null;
+
+		String language = parameters.get(SessionParameter.LOCALE_ISO639_LANGUAGE);
+		String country = parameters.get(SessionParameter.LOCALE_ISO3166_COUNTRY);
+		String variant = parameters.get(SessionParameter.LOCALE_VARIANT);
+
+		if (variant != null) {
+			// all 3 parameter must not be null and valid
+			locale = new Locale(language, country, variant);
+		} else {
+			if (country != null) {
+				// 2 parameter must not be null and valid
+				locale = new Locale(language, country);
+			} else {
+				if (language != null) {
+					// 1 parameter must not be null and valid
+					locale = new Locale(language);
+				} else {
+					locale = Locale.getDefault();
+				}
+			}
+		}
+
+		return locale;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#clear()
+	 */
+	public void clear() {
+		fLock.writeLock().lock();
+		try {
+			int cacheSize = this.determineCacheSize(this.parameters);
+			if (cacheSize == -1) {
+				this.cache = CacheImpl.newInstance();
+			} else {
+				this.cache = CacheImpl.newInstance(cacheSize);
+			}
+			PersistentSessionImpl.log.info("Session Cache Size: " + this.cache.getCacheSize());
+
+			/*
+			 * clear provider cache
+			 */
+			getBinding().clearAllCaches();
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	public void save() {
+		// nop
+	}
+
+	public void cancel() {
+		throw new UnsupportedOperationException("cancel");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getObjectFactory()
+	 */
+	public ObjectFactory getObjectFactory() {
+		return this.objectFactory;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getCheckedOutDocs(int)
+	 */
+	public PagingList<Document> getCheckedOutDocs(int itemsPerPage) {
+		return getCheckedOutDocs(getDefaultContext(), itemsPerPage);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.apache.opencmis.client.api.Session#getCheckedOutDocs(org.apache.
+	 * opencmis.client.api. OperationContext, int)
+	 */
+	public PagingList<Document> getCheckedOutDocs(OperationContext context, final int itemsPerPage) {
+		if (itemsPerPage < 1) {
+			throw new IllegalArgumentException("itemsPerPage must be > 0!");
+		}
+
+		final NavigationService nagivationService = getBinding().getNavigationService();
+		final ObjectFactory objectFactory = getObjectFactory();
+		final OperationContext ctxt = new OperationContextImpl(context);
+
+		return new AbstractPagingList<Document>() {
+
+			@Override
+			protected FetchResult fetchPage(int pageNumber) {
+				int skipCount = pageNumber * getMaxItemsPerPage();
+
+				// get all checked out documents
+				ObjectList checkedOutDocs = nagivationService.getCheckedOutDocs(getRepositoryId(), null, ctxt
+						.getFilterString(), ctxt.getOrderBy(), ctxt.isIncludeAllowableActions(), ctxt
+						.getIncludeRelationships(), ctxt.getRenditionFilterString(), BigInteger
+						.valueOf(getMaxItemsPerPage()), BigInteger.valueOf(skipCount), null);
+
+				// convert objects
+				List<Document> page = new ArrayList<Document>();
+				if (checkedOutDocs.getObjects() != null) {
+					for (ObjectData objectData : checkedOutDocs.getObjects()) {
+						CmisObject doc = objectFactory.convertObject(objectData, ctxt);
+						if (!(doc instanceof Document)) {
+							// should not happen...
+							continue;
+						}
+
+						page.add((Document) doc);
+					}
+				}
+
+				return new FetchResult(page, checkedOutDocs.getNumItems(), checkedOutDocs.hasMoreItems());
+			}
+
+			@Override
+			public int getMaxItemsPerPage() {
+				return itemsPerPage;
+			}
+		};
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#getContentChanges(java.lang.String
+	 * , int)
+	 */
+	public PagingList<ChangeEvent> getContentChanges(String changeLogToken, int itemsPerPage) {
+		throw new CmisRuntimeException("not implemented");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getDefaultContext()
+	 */
+	public OperationContext getDefaultContext() {
+		fLock.readLock().lock();
+		try {
+			return this.context;
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.apache.opencmis.client.api.Session#setDefaultContext(org.apache.
+	 * opencmis.client.api. OperationContext)
+	 */
+	public void setDefaultContext(OperationContext context) {
+		fLock.writeLock().lock();
+		try {
+			this.context = (context == null ? DEFAULT_CONTEXT : context);
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#createOperationContext(java.util
+	 * .Set, boolean, boolean, boolean,
+	 * org.apache.opencmis.commons.enums.IncludeRelationships, java.util.Set,
+	 * boolean, java.lang.String, boolean)
+	 */
+	public OperationContext createOperationContext(Set<String> filter, boolean includeAcls,
+			boolean includeAllowableActions, boolean includePolicies, IncludeRelationships includeRelationships,
+			Set<String> renditionFilter, boolean includePathSegments, String orderBy, boolean cacheEnabled) {
+		return new OperationContextImpl(filter, includeAcls, includeAllowableActions, includePolicies,
+				includeRelationships, renditionFilter, includePathSegments, orderBy, cacheEnabled);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#createObjectId(java.lang.String)
+	 */
+	public ObjectId createObjectId(String id) {
+		return new ObjectIdImpl(id);
+	}
+
+	public Locale getLocale() {
+		return this.locale;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getObject(java.lang.String)
+	 */
+	public CmisObject getObject(ObjectId objectId) {
+		return getObject(objectId, getDefaultContext());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getObject(java.lang.String,
+	 * org.apache.opencmis.client.api.OperationContext)
+	 */
+	public CmisObject getObject(ObjectId objectId, OperationContext context) {
+		if ((objectId == null) || (objectId.getId() == null)) {
+			throw new IllegalArgumentException("Object Id must be set!");
+		}
+		if (context == null) {
+			throw new IllegalArgumentException("Operation context must be set!");
+		}
+
+		CmisObject result = null;
+
+		// ask the cache first
+		if (context.isCacheEnabled()) {
+			result = this.cache.getById(objectId.getId(), context.getCacheKey());
+			if (result != null) {
+				return result;
+			}
+		}
+
+		// get the object
+		ObjectData objectData = this.binding.getObjectService().getObject(getRepositoryId(), objectId.getId(),
+				context.getFilterString(), context.isIncludeAllowableActions(), context.getIncludeRelationships(),
+				context.getRenditionFilterString(), context.isIncludePolicies(), context.isIncludeAcls(), null);
+
+		result = getObjectFactory().convertObject(objectData, context);
+
+		// put into cache
+		if (context.isCacheEnabled()) {
+			this.cache.put(result, context.getCacheKey());
+		}
+
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#getObjectByPath(java.lang.String)
+	 */
+	public CmisObject getObjectByPath(String path) {
+		return getObjectByPath(path, getDefaultContext());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#getObjectByPath(java.lang.String,
+	 * org.apache.opencmis.client.api.OperationContext)
+	 */
+	public CmisObject getObjectByPath(String path, OperationContext context) {
+		if (path == null) {
+			throw new IllegalArgumentException("Path must be set!");
+		}
+		if (context == null) {
+			throw new IllegalArgumentException("Operation context must be set!");
+		}
+
+		CmisObject result = null;
+
+		// ask the cache first
+		if (context.isCacheEnabled()) {
+			result = this.cache.getByPath(path, context.getCacheKey());
+			if (result != null) {
+				return result;
+			}
+		}
+
+		// get the object
+		ObjectData objectData = this.binding.getObjectService().getObjectByPath(getRepositoryId(), path,
+				context.getFilterString(), context.isIncludeAllowableActions(), context.getIncludeRelationships(),
+				context.getRenditionFilterString(), context.isIncludePolicies(), context.isIncludeAcls(), null);
+
+		result = getObjectFactory().convertObject(objectData, context);
+
+		// put into cache
+		if (context.isCacheEnabled()) {
+			this.cache.putPath(path, result, context.getCacheKey());
+		}
+
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getRepositoryInfo()
+	 */
+	public RepositoryInfo getRepositoryInfo() {
+		fLock.readLock().lock();
+		try {
+			return this.repositoryInfo;
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getRootFolder()
+	 */
+	public Folder getRootFolder() {
+		return getRootFolder(getDefaultContext());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * @seeorg.apache.opencmis.client.api.Session#getRootFolder(org.apache.opencmis
+	 * .client.api. OperationContext)
+	 */
+	public Folder getRootFolder(OperationContext context) {
+		String rootFolderId = getRepositoryInfo().getRootFolderId();
+
+		CmisObject rootFolder = getObject(createObjectId(rootFolderId), context);
+		if (!(rootFolder instanceof Folder)) {
+			throw new CmisRuntimeException("Root folder object is not a folder!");
+		}
+
+		return (Folder) rootFolder;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#getTypeChildren(java.lang.String,
+	 * boolean, int)
+	 */
+	public PagingList<ObjectType> getTypeChildren(final String typeId, final boolean includePropertyDefinitions,
+			final int itemsPerPage) {
+		if (itemsPerPage < 1) {
+			throw new IllegalArgumentException("itemsPerPage must be > 0!");
+		}
+
+		final String repositoryId = getRepositoryId();
+		final RepositoryService repositoryService = getBinding().getRepositoryService();
+
+		// set up PagingList object
+		return new AbstractPagingList<ObjectType>() {
+
+			@Override
+			protected FetchResult fetchPage(int pageNumber) {
+				int skipCount = pageNumber * getMaxItemsPerPage();
+
+				// fetch the data
+				TypeDefinitionList tdl = repositoryService.getTypeChildren(repositoryId, typeId,
+						includePropertyDefinitions, BigInteger.valueOf(getMaxItemsPerPage()), BigInteger
+								.valueOf(skipCount), null);
+
+				// convert type definitions
+				List<ObjectType> page = new ArrayList<ObjectType>(tdl.getList().size());
+				for (TypeDefinition typeDefinition : tdl.getList()) {
+					page.add(objectFactory.convertTypeDefinition(typeDefinition));
+				}
+
+				return new FetchResult(page, tdl.getNumItems(), tdl.hasMoreItems());
+			}
+
+			@Override
+			public int getMaxItemsPerPage() {
+				return itemsPerPage;
+			}
+		};
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#getTypeDefinition(java.lang.String
+	 * )
+	 */
+	public ObjectType getTypeDefinition(String typeId) {
+		TypeDefinition typeDefinition = getBinding().getRepositoryService().getTypeDefinition(getRepositoryId(),
+				typeId, null);
+		return objectFactory.convertTypeDefinition(typeDefinition);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#getTypeDescendants(java.lang.String
+	 * , int, boolean)
+	 */
+	public List<Tree<ObjectType>> getTypeDescendants(String typeId, int depth, boolean includePropertyDefinitions) {
+		List<TypeDefinitionContainer> descendants = getBinding().getRepositoryService().getTypeDescendants(
+				getRepositoryId(), typeId, BigInteger.valueOf(depth), includePropertyDefinitions, null);
+
+		return convertTypeDescendants(descendants);
+	}
+
+	/**
+	 * Converts provider <code>TypeDefinitionContainer</code> to API
+	 * <code>Container</code>.
+	 */
+	private List<Tree<ObjectType>> convertTypeDescendants(List<TypeDefinitionContainer> descendantsList) {
+		List<Tree<ObjectType>> result = new ArrayList<Tree<ObjectType>>();
+
+		for (TypeDefinitionContainer container : descendantsList) {
+			ObjectType objectType = objectFactory.convertTypeDefinition(container.getTypeDefinition());
+			List<Tree<ObjectType>> children = convertTypeDescendants(container.getChildren());
+
+			result.add(new ContainerImpl<ObjectType>(objectType, children));
+		}
+
+		return result;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#query(java.lang.String,
+	 * boolean, int)
+	 */
+	public PagingList<QueryResult> query(final String statement, final boolean searchAllVersions, final int itemsPerPage) {
+		return query(statement, searchAllVersions, getDefaultContext(), itemsPerPage);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#query(java.lang.String,
+	 * boolean, org.apache.opencmis.client.api.OperationContext, int)
+	 */
+	public PagingList<QueryResult> query(final String statement, final boolean searchAllVersions,
+			OperationContext context, final int itemsPerPage) {
+
+		final DiscoveryService discoveryService = getBinding().getDiscoveryService();
+		final ObjectFactory of = getObjectFactory();
+		final OperationContext ctxt = new OperationContextImpl(context);
+
+		// set up PagingList object
+		return new AbstractPagingList<QueryResult>() {
+
+			@Override
+			protected FetchResult fetchPage(int pageNumber) {
+				int skipCount = pageNumber * getMaxItemsPerPage();
+
+				// fetch the data
+				ObjectList resultList = discoveryService.query(getRepositoryId(), statement, searchAllVersions, ctxt
+						.isIncludeAllowableActions(), ctxt.getIncludeRelationships(), ctxt.getRenditionFilterString(),
+						BigInteger.valueOf(getMaxItemsPerPage()), BigInteger.valueOf(skipCount), null);
+
+				// convert type definitions
+				List<QueryResult> page = new ArrayList<QueryResult>();
+				if (resultList.getObjects() != null) {
+					for (ObjectData objectData : resultList.getObjects()) {
+						if (objectData == null) {
+							continue;
+						}
+
+						page.add(of.convertQueryResult(objectData));
+					}
+				}
+
+				return new FetchResult(page, resultList.getNumItems(), resultList.hasMoreItems());
+			}
+
+			@Override
+			public int getMaxItemsPerPage() {
+				return itemsPerPage;
+			}
+		};
+	}
+
+	public String setExtensionContext(String context) {
+		throw new CmisRuntimeException("not implemented");
+	}
+
+	public ExtensionHandler setExtensionHandler(String context, ExtensionHandler extensionHandler) {
+		throw new CmisRuntimeException("not implemented");
+	}
+
+	/**
+	 * Connect session object to the provider. This is the very first call after
+	 * a session is created.
+	 * <p>
+	 * In dependency of the parameter set an {@code AtomPub}, a {@code
+	 * WebService} or an {@code InMemory} provider is selected.
+	 */
+	public void connect() {
+		fLock.writeLock().lock();
+		try {
+			this.binding = CmisBindingHelper.createProvider(this.parameters);
+
+			/* get initial repository id from session parameter */
+			String repositoryId = this.determineRepositoryId(this.parameters);
+			if (repositoryId == null) {
+				throw new IllegalStateException("Repository Id is not set!");
+			}
+
+			repositoryInfo = getBinding().getRepositoryService().getRepositoryInfo(repositoryId, null);
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#getBinding()
+	 */
+	public CmisBinding getBinding() {
+		fLock.readLock().lock();
+		try {
+			return this.binding;
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	public Cache getCache() {
+		fLock.readLock().lock();
+		try {
+			return this.cache;
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/**
+	 * Returns the repository id.
+	 */
+	public String getRepositoryId() {
+		return getRepositoryInfo().getId();
+	}
+
+	// creates
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#createDocument(java.util.Map,
+	 * org.apache.opencmis.client.api.ObjectId,
+	 * org.apache.opencmis.client.api.ContentStream,
+	 * org.apache.opencmis.commons.enums.VersioningState, java.util.List,
+	 * java.util.List, java.util.List)
+	 */
+	public ObjectId createDocument(Map<String, ?> properties, ObjectId folderId, ContentStream contentStream,
+			VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces) {
+		if ((folderId != null) && (folderId.getId() == null)) {
+			throw new IllegalArgumentException("Folder Id must be set!");
+		}
+
+		String newId = getBinding().getObjectService().createDocument(getRepositoryId(),
+				objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
+				(folderId == null ? null : folderId.getId()), objectFactory.convertContentStream(contentStream),
+				versioningState, objectFactory.convertPolicies(policies), objectFactory.convertAces(addAces),
+				objectFactory.convertAces(removeAces), null);
+
+		if (newId == null) {
+			return null;
+		}
+
+		return createObjectId(newId);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#createDocumentFromSource(org.apache
+	 * .opencmis.client. api.ObjectId, java.util.Map,
+	 * org.apache.opencmis.client.api.ObjectId,
+	 * org.apache.opencmis.commons.enums.VersioningState, java.util.List,
+	 * java.util.List, java.util.List)
+	 */
+	public ObjectId createDocumentFromSource(ObjectId source, Map<String, ?> properties, ObjectId folderId,
+			VersioningState versioningState, List<Policy> policies, List<Ace> addAces, List<Ace> removeAces) {
+		if ((folderId != null) && (folderId.getId() == null)) {
+			throw new IllegalArgumentException("Folder Id must be set!");
+		}
+
+		// get the type of the source document
+		ObjectType type = null;
+		if (source instanceof CmisObject) {
+			type = ((CmisObject) source).getBaseType();
+		} else {
+			CmisObject sourceObj = getObject(source);
+			type = sourceObj.getType();
+		}
+
+		if (type.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
+			throw new IllegalArgumentException("Source object must be a document!");
+		}
+
+		String newId = getBinding().getObjectService().createDocumentFromSource(getRepositoryId(), source.getId(),
+				objectFactory.convertProperties(properties, type, CREATE_UPDATABILITY),
+				(folderId == null ? null : folderId.getId()), versioningState, objectFactory.convertPolicies(policies),
+				objectFactory.convertAces(addAces), objectFactory.convertAces(removeAces), null);
+
+		if (newId == null) {
+			return null;
+		}
+
+		return createObjectId(newId);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#createFolder(java.util.Map,
+	 * org.apache.opencmis.client.api.ObjectId, java.util.List, java.util.List,
+	 * java.util.List)
+	 */
+	public ObjectId createFolder(Map<String, ?> properties, ObjectId folderId, List<Policy> policies,
+			List<Ace> addAces, List<Ace> removeAces) {
+		if ((folderId != null) && (folderId.getId() == null)) {
+			throw new IllegalArgumentException("Folder Id must be set!");
+		}
+
+		String newId = getBinding().getObjectService().createFolder(getRepositoryId(),
+				objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
+				(folderId == null ? null : folderId.getId()), objectFactory.convertPolicies(policies),
+				objectFactory.convertAces(addAces), objectFactory.convertAces(removeAces), null);
+
+		if (newId == null) {
+			return null;
+		}
+
+		return createObjectId(newId);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.Session#createPolicy(java.util.Map,
+	 * org.apache.opencmis.client.api.ObjectId, java.util.List, java.util.List,
+	 * java.util.List)
+	 */
+	public ObjectId createPolicy(Map<String, ?> properties, ObjectId folderId, List<Policy> policies,
+			List<Ace> addAces, List<Ace> removeAces) {
+		if ((folderId != null) && (folderId.getId() == null)) {
+			throw new IllegalArgumentException("Folder Id must be set!");
+		}
+
+		String newId = getBinding().getObjectService().createPolicy(getRepositoryId(),
+				objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
+				(folderId == null ? null : folderId.getId()), objectFactory.convertPolicies(policies),
+				objectFactory.convertAces(addAces), objectFactory.convertAces(removeAces), null);
+
+		if (newId == null) {
+			return null;
+		}
+
+		return createObjectId(newId);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.Session#createRelationship(java.util.Map,
+	 * java.util.List, java.util.List, java.util.List)
+	 */
+	public ObjectId createRelationship(Map<String, ?> properties, List<Policy> policies, List<Ace> addAces,
+			List<Ace> removeAces) {
+		String newId = getBinding().getObjectService().createRelationship(getRepositoryId(),
+				objectFactory.convertProperties(properties, null, CREATE_UPDATABILITY),
+				objectFactory.convertPolicies(policies), objectFactory.convertAces(addAces),
+				objectFactory.convertAces(removeAces), null);
+
+		if (newId == null) {
+			return null;
+		}
 
-    return createObjectId(newId);
-  }
+		return createObjectId(newId);
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryResultImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryResultImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryResultImpl.java Fri Apr 16 14:07:11 2010
@@ -40,172 +40,182 @@ import org.apache.chemistry.opencmis.com
  */
 public class QueryResultImpl implements QueryResult, Serializable {
 
-  private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-  private Map<String, PropertyData<?>> propertiesById;
-  private Map<String, PropertyData<?>> propertiesByQueryName;
-  private AllowableActions allowableActions;
-  private List<Relationship> relationships;
-  private List<Rendition> renditions;
-
-  /**
-   * Constructor.
-   */
-  public QueryResultImpl(Session session, ObjectData objectData) {
-    if (objectData != null) {
-
-      ObjectFactory of = session.getObjectFactory();
-
-      // handle properties
-      if (objectData.getProperties() != null) {
-        propertiesById = new LinkedHashMap<String, PropertyData<?>>();
-        propertiesByQueryName = new LinkedHashMap<String, PropertyData<?>>();
-
-        List<PropertyData<?>> queryProperties = of.convertQueryProperties(objectData
-            .getProperties());
-
-        for (PropertyData<?> property : queryProperties) {
-          propertiesById.put(property.getId(), property);
-          propertiesByQueryName.put(property.getQueryName(), property);
-        }
-      }
-
-      // handle allowable actions
-      if (objectData.getAllowableActions() != null) {
-        this.allowableActions = objectData.getAllowableActions();
-      }
-
-      // handle relationships
-      if (objectData.getRelationships() != null) {
-        relationships = new ArrayList<Relationship>();
-        for (ObjectData rod : objectData.getRelationships()) {
-          CmisObject relationship = of.convertObject(rod, session.getDefaultContext());
-          if (relationship instanceof Relationship) {
-            relationships.add((Relationship) relationship);
-          }
-        }
-      }
-
-      // handle renditions
-      if (objectData.getRenditions() != null) {
-        this.renditions = new ArrayList<Rendition>();
-        for (RenditionData rd : objectData.getRenditions()) {
-          this.renditions.add(of.convertRendition(null, rd));
-        }
-      }
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getProperties()
-   */
-  public List<PropertyData<?>> getProperties() {
-    return new ArrayList<PropertyData<?>>(propertiesById.values());
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getPropertyById(java.lang.String)
-   */
-  @SuppressWarnings("unchecked")
-  public <T> PropertyData<T> getPropertyById(String id) {
-    return (PropertyData<T>) propertiesById.get(id);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getPropertyByQueryName(java.lang.String)
-   */
-  @SuppressWarnings("unchecked")
-  public <T> PropertyData<T> getPropertyByQueryName(String queryName) {
-    return (PropertyData<T>) propertiesByQueryName.get(queryName);
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getPropertyValueById(java.lang.String)
-   */
-  public <T> T getPropertyValueById(String id) {
-    PropertyData<T> property = getPropertyById(id);
-    if (property == null) {
-      return null;
-    }
-
-    return property.getFirstValue();
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getPropertyValueByQueryName(java.lang.String)
-   */
-  public <T> T getPropertyValueByQueryName(String queryName) {
-    PropertyData<T> property = getPropertyByQueryName(queryName);
-    if (property == null) {
-      return null;
-    }
-
-    return property.getFirstValue();
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getPropertyMultivalueById(java.lang.String)
-   */
-  public <T> List<T> getPropertyMultivalueById(String id) {
-    PropertyData<T> property = getPropertyById(id);
-    if (property == null) {
-      return null;
-    }
-
-    return property.getValues();
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.apache.opencmis.client.api.QueryResult#getPropertyMultivalueByQueryName(java.lang.String)
-   */
-  public <T> List<T> getPropertyMultivalueByQueryName(String queryName) {
-    PropertyData<T> property = getPropertyByQueryName(queryName);
-    if (property == null) {
-      return null;
-    }
-
-    return property.getValues();
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getAllowableActions()
-   */
-  public AllowableActions getAllowableActions() {
-    return allowableActions;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getRelationships()
-   */
-  public List<Relationship> getRelationships() {
-    return relationships;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.opencmis.client.api.QueryResult#getRenditions()
-   */
-  public List<Rendition> getRenditions() {
-    return renditions;
-  }
+	private Map<String, PropertyData<?>> propertiesById;
+	private Map<String, PropertyData<?>> propertiesByQueryName;
+	private AllowableActions allowableActions;
+	private List<Relationship> relationships;
+	private List<Rendition> renditions;
+
+	/**
+	 * Constructor.
+	 */
+	public QueryResultImpl(Session session, ObjectData objectData) {
+		if (objectData != null) {
+
+			ObjectFactory of = session.getObjectFactory();
+
+			// handle properties
+			if (objectData.getProperties() != null) {
+				propertiesById = new LinkedHashMap<String, PropertyData<?>>();
+				propertiesByQueryName = new LinkedHashMap<String, PropertyData<?>>();
+
+				List<PropertyData<?>> queryProperties = of.convertQueryProperties(objectData.getProperties());
+
+				for (PropertyData<?> property : queryProperties) {
+					propertiesById.put(property.getId(), property);
+					propertiesByQueryName.put(property.getQueryName(), property);
+				}
+			}
+
+			// handle allowable actions
+			if (objectData.getAllowableActions() != null) {
+				this.allowableActions = objectData.getAllowableActions();
+			}
+
+			// handle relationships
+			if (objectData.getRelationships() != null) {
+				relationships = new ArrayList<Relationship>();
+				for (ObjectData rod : objectData.getRelationships()) {
+					CmisObject relationship = of.convertObject(rod, session.getDefaultContext());
+					if (relationship instanceof Relationship) {
+						relationships.add((Relationship) relationship);
+					}
+				}
+			}
+
+			// handle renditions
+			if (objectData.getRenditions() != null) {
+				this.renditions = new ArrayList<Rendition>();
+				for (RenditionData rd : objectData.getRenditions()) {
+					this.renditions.add(of.convertRendition(null, rd));
+				}
+			}
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.QueryResult#getProperties()
+	 */
+	public List<PropertyData<?>> getProperties() {
+		return new ArrayList<PropertyData<?>>(propertiesById.values());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.QueryResult#getPropertyById(java.lang.
+	 * String)
+	 */
+	@SuppressWarnings("unchecked")
+	public <T> PropertyData<T> getPropertyById(String id) {
+		return (PropertyData<T>) propertiesById.get(id);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.QueryResult#getPropertyByQueryName(java
+	 * .lang.String)
+	 */
+	@SuppressWarnings("unchecked")
+	public <T> PropertyData<T> getPropertyByQueryName(String queryName) {
+		return (PropertyData<T>) propertiesByQueryName.get(queryName);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.QueryResult#getPropertyValueById(java.
+	 * lang.String)
+	 */
+	public <T> T getPropertyValueById(String id) {
+		PropertyData<T> property = getPropertyById(id);
+		if (property == null) {
+			return null;
+		}
+
+		return property.getFirstValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.QueryResult#getPropertyValueByQueryName
+	 * (java.lang.String)
+	 */
+	public <T> T getPropertyValueByQueryName(String queryName) {
+		PropertyData<T> property = getPropertyByQueryName(queryName);
+		if (property == null) {
+			return null;
+		}
+
+		return property.getFirstValue();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.QueryResult#getPropertyMultivalueById(
+	 * java.lang.String)
+	 */
+	public <T> List<T> getPropertyMultivalueById(String id) {
+		PropertyData<T> property = getPropertyById(id);
+		if (property == null) {
+			return null;
+		}
+
+		return property.getValues();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.api.QueryResult#getPropertyMultivalueByQueryName
+	 * (java.lang.String)
+	 */
+	public <T> List<T> getPropertyMultivalueByQueryName(String queryName) {
+		PropertyData<T> property = getPropertyByQueryName(queryName);
+		if (property == null) {
+			return null;
+		}
+
+		return property.getValues();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.QueryResult#getAllowableActions()
+	 */
+	public AllowableActions getAllowableActions() {
+		return allowableActions;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.QueryResult#getRelationships()
+	 */
+	public List<Relationship> getRelationships() {
+		return relationships;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.api.QueryResult#getRenditions()
+	 */
+	public List<Rendition> getRenditions() {
+		return renditions;
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RenditionImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RenditionImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RenditionImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/RenditionImpl.java Fri Apr 16 14:07:11 2010
@@ -33,68 +33,63 @@ import org.apache.chemistry.opencmis.com
  */
 public class RenditionImpl extends RenditionDataImpl implements Rendition {
 
-  private Session session;
-  private String objectId;
+	private Session session;
+	private String objectId;
 
-  /**
-   * Constructor.
-   */
-  public RenditionImpl(Session session, String objectId, String streamId,
-      String renditionDocumentId, String kind, long length, String mimeType, String title,
-      int height, int width) {
-        super(streamId, mimeType, BigInteger.valueOf(length), kind, title,
-                BigInteger.valueOf(width), BigInteger.valueOf(height),
-                renditionDocumentId);
-    this.session = session;
-    this.objectId = objectId;
-  }
-
-
-  public long getLength() {
-    return fLength == null ? -1 : fLength.longValue();
-  }
-
-
-  public long getHeight() {
-    return fHeight == null ? -1 : fHeight.longValue();
-  }
-
-  public long getWidth() {
-    return fWidth == null ? -1 : fWidth.longValue();
-  }
-
-  public Document getRenditionDocument() {
-    return getRenditionDocument(session.getDefaultContext());
-  }
-
-  public Document getRenditionDocument(OperationContext context) {
-    if (fRenditionDocumentId == null) {
-      return null;
-    }
-    CmisObject rendDoc = session.getObject(session.createObjectId(fRenditionDocumentId),
-        context);
-    if (!(rendDoc instanceof Document)) {
-      return null;
-    }
-
-    return (Document) rendDoc;
-  }
-
-  public ContentStream getContentStream() {
-    if ((objectId == null) || (fStreamId == null)) {
-      return null;
-    }
-
-    ContentStream contentStream = session.getBinding().getObjectService().getContentStream(
-        session.getRepositoryInfo().getId(), objectId, fStreamId, null, null, null);
-    if (contentStream == null) {
-      return null;
-    }
-
-    long length = contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue();
-
-    return session.getObjectFactory().createContentStream(contentStream.getFileName(), length,
-        contentStream.getMimeType(), contentStream.getStream());
-  }
+	/**
+	 * Constructor.
+	 */
+	public RenditionImpl(Session session, String objectId, String streamId, String renditionDocumentId, String kind,
+			long length, String mimeType, String title, int height, int width) {
+		super(streamId, mimeType, BigInteger.valueOf(length), kind, title, BigInteger.valueOf(width), BigInteger
+				.valueOf(height), renditionDocumentId);
+		this.session = session;
+		this.objectId = objectId;
+	}
+
+	public long getLength() {
+		return fLength == null ? -1 : fLength.longValue();
+	}
+
+	public long getHeight() {
+		return fHeight == null ? -1 : fHeight.longValue();
+	}
+
+	public long getWidth() {
+		return fWidth == null ? -1 : fWidth.longValue();
+	}
+
+	public Document getRenditionDocument() {
+		return getRenditionDocument(session.getDefaultContext());
+	}
+
+	public Document getRenditionDocument(OperationContext context) {
+		if (fRenditionDocumentId == null) {
+			return null;
+		}
+		CmisObject rendDoc = session.getObject(session.createObjectId(fRenditionDocumentId), context);
+		if (!(rendDoc instanceof Document)) {
+			return null;
+		}
+
+		return (Document) rendDoc;
+	}
+
+	public ContentStream getContentStream() {
+		if ((objectId == null) || (fStreamId == null)) {
+			return null;
+		}
+
+		ContentStream contentStream = session.getBinding().getObjectService().getContentStream(
+				session.getRepositoryInfo().getId(), objectId, fStreamId, null, null, null);
+		if (contentStream == null) {
+			return null;
+		}
+
+		long length = contentStream.getBigLength() == null ? -1 : contentStream.getBigLength().longValue();
+
+		return session.getObjectFactory().createContentStream(contentStream.getFileName(), length,
+				contentStream.getMimeType(), contentStream.getStream());
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/Cache.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/Cache.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/Cache.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/Cache.java Fri Apr 16 14:07:11 2010
@@ -30,21 +30,21 @@ import org.apache.chemistry.opencmis.cli
  */
 public interface Cache {
 
-  boolean containsId(String objectId, String cacheKey);
+	boolean containsId(String objectId, String cacheKey);
 
-  boolean containsPath(String path, String cacheKey);
+	boolean containsPath(String path, String cacheKey);
 
-  void put(CmisObject object, String cacheKey);
+	void put(CmisObject object, String cacheKey);
 
-  void putPath(String path, CmisObject object, String cacheKey);
+	void putPath(String path, CmisObject object, String cacheKey);
 
-  CmisObject getById(String objectId, String cacheKey);
+	CmisObject getById(String objectId, String cacheKey);
 
-  CmisObject getByPath(String path, String cacheKey);
+	CmisObject getByPath(String path, String cacheKey);
 
-  void clear();
+	void clear();
 
-  void resetPathCache();
+	void resetPathCache();
 
-  int getCacheSize();
+	int getCacheSize();
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/cache/CacheImpl.java Fri Apr 16 14:07:11 2010
@@ -28,265 +28,261 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 
 /**
- * Non synchronized cache implementation. The cache is limited to a specific size of entries and
- * works in a LRU mode.
+ * Non synchronized cache implementation. The cache is limited to a specific
+ * size of entries and works in a LRU mode.
  */
 public class CacheImpl implements Cache, Serializable {
 
-  private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-  private static final float HASHTABLE_LOAD_FACTOR = 0.75f;
+	private static final float HASHTABLE_LOAD_FACTOR = 0.75f;
 
-  private int cacheSize;
+	private int cacheSize;
 
-  private LinkedHashMap<String, Map<String, CmisObject>> objectMap;
-  private Map<String, String> pathToIdMap;
+	private LinkedHashMap<String, Map<String, CmisObject>> objectMap;
+	private Map<String, String> pathToIdMap;
 
-  private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
-
-  /**
-   * Creates a new cache instance with a default size.
-   */
-  public static Cache newInstance() {
-    return new CacheImpl();
-  }
-
-  /**
-   * Creates a new cache instance with the given size.
-   */
-  public static Cache newInstance(int cacheSize) {
-    return new CacheImpl(cacheSize);
-  }
-
-  /**
-   * Default constructor.
-   */
-  protected CacheImpl() {
-    this(1000); // default cache size
-  }
-
-  /**
-   * Constructor taking a cache size.
-   */
-  protected CacheImpl(int cacheSize) {
-    this.cacheSize = cacheSize;
-    initialize();
-  }
-
-  /**
-   * Sets up the internal objects.
-   */
-  protected void initialize() {
-    fLock.writeLock().lock();
-    try {
-      int hashTableCapacity = (int) Math.ceil(cacheSize / HASHTABLE_LOAD_FACTOR) + 1;
-
-      final int cs = cacheSize;
-
-      objectMap = new LinkedHashMap<String, Map<String, CmisObject>>(hashTableCapacity,
-          HASHTABLE_LOAD_FACTOR) {
-
-        private static final long serialVersionUID = 1L;
-
-        @Override
-        protected boolean removeEldestEntry(Map.Entry<String, Map<String, CmisObject>> eldest) {
-          return size() > cs;
-        }
-      };
-
-      resetPathCache();
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#clear()
-   */
-  public void clear() {
-    initialize();
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#resetPathCache()
-   */
-  public void resetPathCache() {
-    fLock.writeLock().lock();
-    try {
-      pathToIdMap = new HashMap<String, String>();
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#containsId(java.lang.String,
-   * java.lang.String)
-   */
-  public boolean containsId(String objectId, String cacheKey) {
-    fLock.readLock().lock();
-    try {
-      if (!objectMap.containsKey(objectId)) {
-        return false;
-      }
-
-      return objectMap.get(objectId).containsKey(cacheKey);
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#containsPath(java.lang.String,
-   * java.lang.String)
-   */
-  public boolean containsPath(String path, String cacheKey) {
-    fLock.readLock().lock();
-    try {
-      if (!pathToIdMap.containsKey(path)) {
-        return false;
-      }
-
-      return containsId(pathToIdMap.get(path), cacheKey);
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#getById(java.lang.String, java.lang.String)
-   */
-  public CmisObject getById(String objectId, String cacheKey) {
-    fLock.readLock().lock();
-    try {
-      Map<String, CmisObject> cacheKeyMap = objectMap.get(objectId);
-      if (cacheKeyMap == null) {
-        return null; // not found
-      }
-
-      return cacheKeyMap.get(cacheKey);
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#getByPath(java.lang.String,
-   * java.lang.String)
-   */
-  public CmisObject getByPath(String path, String cacheKey) {
-    fLock.readLock().lock();
-    try {
-      String id = pathToIdMap.get(path);
-      if (id == null) {
-        return null; // not found
-      }
-
-      CmisObject object = getById(id, cacheKey);
-      if ((object == null) && (!objectMap.containsKey(id))) {
-        // clean up
-        fLock.readLock().unlock();
-        fLock.writeLock().lock();
-        try {
-          pathToIdMap.remove(path);
-        }
-        finally {
-          fLock.writeLock().unlock();
-          fLock.readLock().lock();
-        }
-      }
-
-      return object;
-    }
-    finally {
-      fLock.readLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * org.apache.opencmis.client.runtime.cache.Cache#put(org.apache.opencmis.client.api.CmisObject,
-   * java.lang.String)
-   */
-  public void put(CmisObject object, String cacheKey) {
-    // no object, no cache key - no cache
-    if ((object == null) || (cacheKey == null)) {
-      return;
-    }
-
-    // no id - no cache
-    if (object.getId() == null) {
-      return;
-    }
-
-    fLock.writeLock().lock();
-    try {
-      // get cache key map
-      Map<String, CmisObject> cacheKeyMap = objectMap.get(object.getId());
-      if (cacheKeyMap == null) {
-        cacheKeyMap = new HashMap<String, CmisObject>();
-        objectMap.put(object.getId(), cacheKeyMap);
-      }
-
-      // put into id cache
-      cacheKeyMap.put(cacheKey, object);
-
-      // folders may have a path, use it!
-      String path = object.getPropertyValue(PropertyIds.PATH);
-      if (path != null) {
-        pathToIdMap.put(path, object.getId());
-      }
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#putPath(java.lang.String,
-   * org.apache.opencmis.client.api.CmisObject, java.lang.String)
-   */
-  public void putPath(String path, CmisObject object, String cacheKey) {
-    fLock.writeLock().lock();
-    try {
-      put(object, cacheKey);
-
-      if ((object != null) && (object.getId() != null) && (cacheKey != null)) {
-        pathToIdMap.put(path, object.getId());
-      }
-    }
-    finally {
-      fLock.writeLock().unlock();
-    }
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see org.apache.opencmis.client.runtime.cache.Cache#getCacheSize()
-   */
-  public int getCacheSize() {
-    return this.cacheSize;
-  }
+	private final ReentrantReadWriteLock fLock = new ReentrantReadWriteLock();
+
+	/**
+	 * Creates a new cache instance with a default size.
+	 */
+	public static Cache newInstance() {
+		return new CacheImpl();
+	}
+
+	/**
+	 * Creates a new cache instance with the given size.
+	 */
+	public static Cache newInstance(int cacheSize) {
+		return new CacheImpl(cacheSize);
+	}
+
+	/**
+	 * Default constructor.
+	 */
+	protected CacheImpl() {
+		this(1000); // default cache size
+	}
+
+	/**
+	 * Constructor taking a cache size.
+	 */
+	protected CacheImpl(int cacheSize) {
+		this.cacheSize = cacheSize;
+		initialize();
+	}
+
+	/**
+	 * Sets up the internal objects.
+	 */
+	protected void initialize() {
+		fLock.writeLock().lock();
+		try {
+			int hashTableCapacity = (int) Math.ceil(cacheSize / HASHTABLE_LOAD_FACTOR) + 1;
+
+			final int cs = cacheSize;
+
+			objectMap = new LinkedHashMap<String, Map<String, CmisObject>>(hashTableCapacity, HASHTABLE_LOAD_FACTOR) {
+
+				private static final long serialVersionUID = 1L;
+
+				@Override
+				protected boolean removeEldestEntry(Map.Entry<String, Map<String, CmisObject>> eldest) {
+					return size() > cs;
+				}
+			};
+
+			resetPathCache();
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.runtime.cache.Cache#clear()
+	 */
+	public void clear() {
+		initialize();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.runtime.cache.Cache#resetPathCache()
+	 */
+	public void resetPathCache() {
+		fLock.writeLock().lock();
+		try {
+			pathToIdMap = new HashMap<String, String>();
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.runtime.cache.Cache#containsId(java.lang.String
+	 * , java.lang.String)
+	 */
+	public boolean containsId(String objectId, String cacheKey) {
+		fLock.readLock().lock();
+		try {
+			if (!objectMap.containsKey(objectId)) {
+				return false;
+			}
+
+			return objectMap.get(objectId).containsKey(cacheKey);
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.runtime.cache.Cache#containsPath(java.lang
+	 * .String, java.lang.String)
+	 */
+	public boolean containsPath(String path, String cacheKey) {
+		fLock.readLock().lock();
+		try {
+			if (!pathToIdMap.containsKey(path)) {
+				return false;
+			}
+
+			return containsId(pathToIdMap.get(path), cacheKey);
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.runtime.cache.Cache#getById(java.lang.String,
+	 * java.lang.String)
+	 */
+	public CmisObject getById(String objectId, String cacheKey) {
+		fLock.readLock().lock();
+		try {
+			Map<String, CmisObject> cacheKeyMap = objectMap.get(objectId);
+			if (cacheKeyMap == null) {
+				return null; // not found
+			}
+
+			return cacheKeyMap.get(cacheKey);
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.runtime.cache.Cache#getByPath(java.lang.String
+	 * , java.lang.String)
+	 */
+	public CmisObject getByPath(String path, String cacheKey) {
+		fLock.readLock().lock();
+		try {
+			String id = pathToIdMap.get(path);
+			if (id == null) {
+				return null; // not found
+			}
+
+			CmisObject object = getById(id, cacheKey);
+			if ((object == null) && (!objectMap.containsKey(id))) {
+				// clean up
+				fLock.readLock().unlock();
+				fLock.writeLock().lock();
+				try {
+					pathToIdMap.remove(path);
+				} finally {
+					fLock.writeLock().unlock();
+					fLock.readLock().lock();
+				}
+			}
+
+			return object;
+		} finally {
+			fLock.readLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.runtime.cache.Cache#put(org.apache.opencmis
+	 * .client.api.CmisObject, java.lang.String)
+	 */
+	public void put(CmisObject object, String cacheKey) {
+		// no object, no cache key - no cache
+		if ((object == null) || (cacheKey == null)) {
+			return;
+		}
+
+		// no id - no cache
+		if (object.getId() == null) {
+			return;
+		}
+
+		fLock.writeLock().lock();
+		try {
+			// get cache key map
+			Map<String, CmisObject> cacheKeyMap = objectMap.get(object.getId());
+			if (cacheKeyMap == null) {
+				cacheKeyMap = new HashMap<String, CmisObject>();
+				objectMap.put(object.getId(), cacheKeyMap);
+			}
+
+			// put into id cache
+			cacheKeyMap.put(cacheKey, object);
+
+			// folders may have a path, use it!
+			String path = object.getPropertyValue(PropertyIds.PATH);
+			if (path != null) {
+				pathToIdMap.put(path, object.getId());
+			}
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.opencmis.client.runtime.cache.Cache#putPath(java.lang.String,
+	 * org.apache.opencmis.client.api.CmisObject, java.lang.String)
+	 */
+	public void putPath(String path, CmisObject object, String cacheKey) {
+		fLock.writeLock().lock();
+		try {
+			put(object, cacheKey);
+
+			if ((object != null) && (object.getId() != null) && (cacheKey != null)) {
+				pathToIdMap.put(path, object.getId());
+			}
+		} finally {
+			fLock.writeLock().unlock();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.opencmis.client.runtime.cache.Cache#getCacheSize()
+	 */
+	public int getCacheSize() {
+		return this.cacheSize;
+	}
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java?rev=934889&r1=934888&r2=934889&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/objecttype/DocumentTypeImpl.java Fri Apr 16 14:07:11 2010
@@ -31,37 +31,35 @@ import org.apache.chemistry.opencmis.com
 /**
  * Document type.
  */
-public class DocumentTypeImpl extends DocumentTypeDefinitionImpl implements
-        DocumentType {
+public class DocumentTypeImpl extends DocumentTypeDefinitionImpl implements DocumentType {
 
-    private static final long serialVersionUID = 1L;
+	private static final long serialVersionUID = 1L;
 
-    private ObjectTypeHelper helper;
+	private ObjectTypeHelper helper;
 
-    public DocumentTypeImpl(Session session,
-            DocumentTypeDefinition typeDefinition) {
-        initialize(typeDefinition);
-        helper = new ObjectTypeHelper(session, this);
-    }
-
-    public ObjectType getBaseType() {
-        return helper.getBaseType();
-    }
-
-    public PagingList<ObjectType> getChildren(int itemsPerPage) {
-        return helper.getChildren(itemsPerPage);
-    }
-
-    public List<Tree<ObjectType>> getDescendants(int depth) {
-        return helper.getDescendants(depth);
-    }
-
-    public ObjectType getParentType() {
-        return helper.getParentType();
-    }
-
-    public boolean isBaseType() {
-        return helper.isBaseType();
-    }
+	public DocumentTypeImpl(Session session, DocumentTypeDefinition typeDefinition) {
+		initialize(typeDefinition);
+		helper = new ObjectTypeHelper(session, this);
+	}
+
+	public ObjectType getBaseType() {
+		return helper.getBaseType();
+	}
+
+	public PagingList<ObjectType> getChildren(int itemsPerPage) {
+		return helper.getChildren(itemsPerPage);
+	}
+
+	public List<Tree<ObjectType>> getDescendants(int depth) {
+		return helper.getDescendants(depth);
+	}
+
+	public ObjectType getParentType() {
+		return helper.getParentType();
+	}
+
+	public boolean isBaseType() {
+		return helper.isBaseType();
+	}
 
 }



Mime
View raw message