chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r934878 [3/13] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/ main/java/org/apache/chemistry/opencmis/inmemory/clientprovider/ mai...
Date Fri, 16 Apr 2010 14:00:25 GMT
Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/AtomLinkInfoProvider.java Fri Apr 16 14:00:23 2010
@@ -39,274 +39,276 @@ import org.apache.chemistry.opencmis.ser
 import org.apache.chemistry.opencmis.server.spi.ObjectInfoImpl;
 
 /**
- * For the Atom binding more information might be required than the result of a service call
- * provides (mainly to fill all the links). This class fills the objectInfoHolder that was introduced
- * for this purpose
- *
+ * For the Atom binding more information might be required than the result of a
+ * service call provides (mainly to fill all the links). This class fills the
+ * objectInfoHolder that was introduced for this purpose
+ * 
  * @author Jens
- *
+ * 
  */
 public class AtomLinkInfoProvider {
 
-  private StoreManager fStoreManager;
-
-  public AtomLinkInfoProvider(StoreManager storeManager) {
-    fStoreManager = storeManager;
-  }
-
-  /**
-   * FillObjectInfoHolder object with required information needed for Atom binding for a single object
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   */
-  public void fillInformationForAtomLinks(String repositoryId, StoredObject so, ObjectInfoHolder objectInfos) {
-    if (null == objectInfos || null == so)
-      return;
-    TypeDefinition typeDef = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
-
-    ObjectInfoImpl objInfo = new ObjectInfoImpl();
-   // Fill all setters:
-    objInfo.setId(so.getId());
-    objInfo.setName(so.getName());
-    objInfo.setCreatedBy(so.getCreatedBy()); //!
-    objInfo.setCreationDate(so.getCreatedAt()); //!
-    objInfo.setLastModificationDate(so.getModifiedAt());
-    objInfo.setTypeId(so.getTypeId());
-    objInfo.setBaseType(typeDef.getBaseTypeId());
-
-    // versioning information:
-    if (so instanceof DocumentVersion) {
-      DocumentVersion ver = (DocumentVersion) so;
-      DocumentVersion pwc = ver.getParentDocument().getPwc();
-      objInfo.setIsCurrentVersion (ver == ver.getParentDocument().getLatestVersion(false));
-      objInfo.setVersionSeriesId(ver.getParentDocument().getId());
-      objInfo.setWorkingCopyId(pwc==null ? null : pwc.getId());
-      objInfo.setWorkingCopyOriginalId(pwc==ver ? ver.getParentDocument().getLatestVersion(false).getId() : null);
-    } else if (so instanceof VersionedDocument) {
-      VersionedDocument doc = (VersionedDocument) so;
-      DocumentVersion pwc = doc.getPwc();
-      objInfo.setIsCurrentVersion (false);
-      objInfo.setVersionSeriesId(doc.getId());
-      objInfo.setWorkingCopyId(pwc==null ? null : pwc.getId());
-      objInfo.setWorkingCopyOriginalId(null);
-    } else { // unversioned document
-      objInfo.setIsCurrentVersion (true);
-      objInfo.setVersionSeriesId(null);
-      objInfo.setWorkingCopyId(null);
-      objInfo.setWorkingCopyOriginalId(null);
-    }
-
-    if (so instanceof Content) {
-      Content cont = ((Content)so);
-      objInfo.setHasContent(cont.getContent(0, -1) != null);
-      objInfo.setContentType(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getMimeType() : null);
-      objInfo.setFileName(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getFileName() : null);
-    } else {
-      objInfo.setHasContent(false);
-      objInfo.setContentType(null);
-      objInfo.setFileName(null);
-    }
-
-    // Filing
-    if (so instanceof Filing) {
-      Filing sop = ((Filing)so);
-      objInfo.setHasParent(!sop.getParents().isEmpty());
-    } else {
-      objInfo.setHasParent(false);
-    }
-
-    // Renditions, currently not supported by in-memory provider
-    objInfo.setRenditionInfos(null);
-
-    // Relationships, currently not supported by in-memory provider
-    objInfo.setSupportsRelationships(false);
-    objInfo.setRelationshipSourceIds(null);
-    objInfo.setRelationshipTargetIds(null);
-
-    // Policies, currently not supported by in-memory provider
-    objInfo.setSupportsPolicies(false);
-
-    // ACLs, currently not supported by in-memory provider
-    objInfo.setHasAcl(false);
-
-    objInfo.setSupportsDescendants(true);
-    objInfo.setSupportsFolderTree(true);
-
-    objectInfos.addObjectInfo(objInfo);
-  }
-
- /**
-   * FillObjectInfoHolder object with required information needed for Atom binding for a single object
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   */
-  public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHolder objectInfos) {
-    if (null == objectInfos || null == objectId)
-      return;
-
-    ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-    StoredObject so = objectStore.getObjectById(objectId);
-    fillInformationForAtomLinks(repositoryId, so, objectInfos);
-  }
-
-  /**
-   * FillObjectInfoHolder object with required information needed for Atom binding
-   * after a getChildren() call in navigation service
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   * @param objList
-   *          result of getChildren call
-   */
-  public void fillInformationForAtomLinks(String repositoryId, String objectId,
-      ObjectInfoHolder objectInfos, ObjectInFolderList objList) {
-
-    if (null == objectInfos || null == objList || null == objectId)
-      return;
-
-    // Fill object information for requested object
-    fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
-
-    // Fill object information for all children in result list
-    for (ObjectInFolderData object : objList.getObjects()) {
-      fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfos);
-    }
-  }
-
-  /**
-   * FillObjectInfoHolder object with required information needed for Atom binding
-   * for an object list
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   * @param objList
-   *          result of getChildren call
-   */
-  public void fillInformationForAtomLinks(String repositoryId, String objectId,
-      ObjectInfoHolder objectInfos, ObjectList objList) {
-
-    if (null != objectId) {
-      // Fill object information for requested object
-      fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
-    }
-
-    if (null != objList && null != objList.getObjects()) {
-      // Fill object information for all children in result list
-      List<ObjectData> listObjects = objList.getObjects();
-      if (null != listObjects)
-        for (ObjectData object : listObjects) {
-          fillInformationForAtomLinks(repositoryId, object.getId(), objectInfos);
-        }
-    }
-
-  }
-
-  /**
-   * FillObjectInfoHolder object with required information needed for Atom binding
-   * for an ObjectInFolderContainer
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   * @param objList
-   *          result of getChildren call
-   */
-  private void fillInformationForAtomLinks(String repositoryId,
-      ObjectInfoHolder objectInfos, ObjectInFolderContainer oifc) {
-
-    if (null == objectInfos || null == oifc)
-      return;
-
-    // Fill object information for all elements in result list
-    fillInformationForAtomLinks(repositoryId, objectInfos, oifc.getObject());
-
-    if (null!=oifc.getChildren())
-      for (ObjectInFolderContainer object : oifc.getChildren()) {
-        // call recursively
-          fillInformationForAtomLinks(repositoryId, objectInfos, object);
-      }
-  }
-
-  /**
-   * FillObjectInfoHolder object with required information needed for Atom binding
-   * for a list with ObjectInFolderContainers
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   * @param oifcList
-   *          result of getDescendants call
-   */
-  public void fillInformationForAtomLinks(String repositoryId, String objectId,
-      ObjectInfoHolder objectInfos, List<ObjectInFolderContainer> oifcList) {
-
-    if (null == objectInfos || null == oifcList || null == objectId)
-      return;
-
-    // Fill object information for requested object
-    fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
-
-    for (ObjectInFolderContainer object : oifcList) {
-      fillInformationForAtomLinks(repositoryId, objectInfos, object);
-    }
-  }
-
-  private void fillInformationForAtomLinks(String repositoryId,
-      ObjectInfoHolder objectInfos, ObjectInFolderData object) {
-
-    fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfos);
-  }
-
-  /**
-   * FillObjectInfoHolder object with required information needed for Atom binding
-   * for a list with ObjectParentData objects
-   *
-   * @param repositoryId
-   *          id of repository
-   * @param objectId
-   *          object to retrieve information for
-   * @param objectInfos
-   *          Holder to fill with information
-   * @param objParents
-   *          result of getObjectParents call
-   */
-  public void fillInformationForAtomLinksGetParents(String repositoryId, String objectId,
-      ObjectInfoHolder objectInfos, List<ObjectParentData> objParents) {
-
-    if (null == objectInfos || null == objParents || null == objectId)
-      return;
-
-    // Fill object information for requested object
-    fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
-
-    for (ObjectParentData object : objParents) {
-      fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfos);
-    }
-  }
+	private StoreManager fStoreManager;
 
+	public AtomLinkInfoProvider(StoreManager storeManager) {
+		fStoreManager = storeManager;
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding for a single object
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 */
+	public void fillInformationForAtomLinks(String repositoryId, StoredObject so, ObjectInfoHolder objectInfos) {
+		if (null == objectInfos || null == so)
+			return;
+		TypeDefinition typeDef = fStoreManager.getTypeById(repositoryId, so.getTypeId()).getTypeDefinition();
+
+		ObjectInfoImpl objInfo = new ObjectInfoImpl();
+		// Fill all setters:
+		objInfo.setId(so.getId());
+		objInfo.setName(so.getName());
+		objInfo.setCreatedBy(so.getCreatedBy()); // !
+		objInfo.setCreationDate(so.getCreatedAt()); // !
+		objInfo.setLastModificationDate(so.getModifiedAt());
+		objInfo.setTypeId(so.getTypeId());
+		objInfo.setBaseType(typeDef.getBaseTypeId());
+
+		// versioning information:
+		if (so instanceof DocumentVersion) {
+			DocumentVersion ver = (DocumentVersion) so;
+			DocumentVersion pwc = ver.getParentDocument().getPwc();
+			objInfo.setIsCurrentVersion(ver == ver.getParentDocument().getLatestVersion(false));
+			objInfo.setVersionSeriesId(ver.getParentDocument().getId());
+			objInfo.setWorkingCopyId(pwc == null ? null : pwc.getId());
+			objInfo.setWorkingCopyOriginalId(pwc == ver ? ver.getParentDocument().getLatestVersion(false).getId()
+					: null);
+		} else if (so instanceof VersionedDocument) {
+			VersionedDocument doc = (VersionedDocument) so;
+			DocumentVersion pwc = doc.getPwc();
+			objInfo.setIsCurrentVersion(false);
+			objInfo.setVersionSeriesId(doc.getId());
+			objInfo.setWorkingCopyId(pwc == null ? null : pwc.getId());
+			objInfo.setWorkingCopyOriginalId(null);
+		} else { // unversioned document
+			objInfo.setIsCurrentVersion(true);
+			objInfo.setVersionSeriesId(null);
+			objInfo.setWorkingCopyId(null);
+			objInfo.setWorkingCopyOriginalId(null);
+		}
+
+		if (so instanceof Content) {
+			Content cont = ((Content) so);
+			objInfo.setHasContent(cont.getContent(0, -1) != null);
+			objInfo.setContentType(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getMimeType() : null);
+			objInfo.setFileName(cont.getContent(0, -1) != null ? cont.getContent(0, -1).getFileName() : null);
+		} else {
+			objInfo.setHasContent(false);
+			objInfo.setContentType(null);
+			objInfo.setFileName(null);
+		}
+
+		// Filing
+		if (so instanceof Filing) {
+			Filing sop = ((Filing) so);
+			objInfo.setHasParent(!sop.getParents().isEmpty());
+		} else {
+			objInfo.setHasParent(false);
+		}
+
+		// Renditions, currently not supported by in-memory provider
+		objInfo.setRenditionInfos(null);
+
+		// Relationships, currently not supported by in-memory provider
+		objInfo.setSupportsRelationships(false);
+		objInfo.setRelationshipSourceIds(null);
+		objInfo.setRelationshipTargetIds(null);
+
+		// Policies, currently not supported by in-memory provider
+		objInfo.setSupportsPolicies(false);
+
+		// ACLs, currently not supported by in-memory provider
+		objInfo.setHasAcl(false);
+
+		objInfo.setSupportsDescendants(true);
+		objInfo.setSupportsFolderTree(true);
+
+		objectInfos.addObjectInfo(objInfo);
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding for a single object
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 */
+	public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHolder objectInfos) {
+		if (null == objectInfos || null == objectId)
+			return;
+
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		StoredObject so = objectStore.getObjectById(objectId);
+		fillInformationForAtomLinks(repositoryId, so, objectInfos);
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding after a getChildren() call in navigation service
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 * @param objList
+	 *            result of getChildren call
+	 */
+	public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHolder objectInfos,
+			ObjectInFolderList objList) {
+
+		if (null == objectInfos || null == objList || null == objectId)
+			return;
+
+		// Fill object information for requested object
+		fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
+
+		// Fill object information for all children in result list
+		for (ObjectInFolderData object : objList.getObjects()) {
+			fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfos);
+		}
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding for an object list
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 * @param objList
+	 *            result of getChildren call
+	 */
+	public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHolder objectInfos,
+			ObjectList objList) {
+
+		if (null != objectId) {
+			// Fill object information for requested object
+			fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
+		}
+
+		if (null != objList && null != objList.getObjects()) {
+			// Fill object information for all children in result list
+			List<ObjectData> listObjects = objList.getObjects();
+			if (null != listObjects)
+				for (ObjectData object : listObjects) {
+					fillInformationForAtomLinks(repositoryId, object.getId(), objectInfos);
+				}
+		}
+
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding for an ObjectInFolderContainer
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 * @param objList
+	 *            result of getChildren call
+	 */
+	private void fillInformationForAtomLinks(String repositoryId, ObjectInfoHolder objectInfos,
+			ObjectInFolderContainer oifc) {
+
+		if (null == objectInfos || null == oifc)
+			return;
+
+		// Fill object information for all elements in result list
+		fillInformationForAtomLinks(repositoryId, objectInfos, oifc.getObject());
+
+		if (null != oifc.getChildren())
+			for (ObjectInFolderContainer object : oifc.getChildren()) {
+				// call recursively
+				fillInformationForAtomLinks(repositoryId, objectInfos, object);
+			}
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding for a list with ObjectInFolderContainers
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 * @param oifcList
+	 *            result of getDescendants call
+	 */
+	public void fillInformationForAtomLinks(String repositoryId, String objectId, ObjectInfoHolder objectInfos,
+			List<ObjectInFolderContainer> oifcList) {
+
+		if (null == objectInfos || null == oifcList || null == objectId)
+			return;
+
+		// Fill object information for requested object
+		fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
+
+		for (ObjectInFolderContainer object : oifcList) {
+			fillInformationForAtomLinks(repositoryId, objectInfos, object);
+		}
+	}
+
+	private void fillInformationForAtomLinks(String repositoryId, ObjectInfoHolder objectInfos,
+			ObjectInFolderData object) {
+
+		fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfos);
+	}
+
+	/**
+	 * FillObjectInfoHolder object with required information needed for Atom
+	 * binding for a list with ObjectParentData objects
+	 * 
+	 * @param repositoryId
+	 *            id of repository
+	 * @param objectId
+	 *            object to retrieve information for
+	 * @param objectInfos
+	 *            Holder to fill with information
+	 * @param objParents
+	 *            result of getObjectParents call
+	 */
+	public void fillInformationForAtomLinksGetParents(String repositoryId, String objectId,
+			ObjectInfoHolder objectInfos, List<ObjectParentData> objParents) {
+
+		if (null == objectInfos || null == objParents || null == objectId)
+			return;
+
+		// Fill object information for requested object
+		fillInformationForAtomLinks(repositoryId, objectId, objectInfos);
+
+		for (ObjectParentData object : objParents) {
+			fillInformationForAtomLinks(repositoryId, object.getObject().getId(), objectInfos);
+		}
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java Fri Apr 16 14:00:23 2010
@@ -41,101 +41,101 @@ import org.apache.chemistry.opencmis.ser
 
 public class InMemoryDiscoveryServiceImpl implements CmisDiscoveryService {
 
-  private StoreManager fStoreManager;
-  AtomLinkInfoProvider fAtomLinkProvider;
-  InMemoryNavigationServiceImpl fNavigationService; // real implementation of the service
-  InMemoryRepositoryServiceImpl fRepositoryService;
-
-  public InMemoryDiscoveryServiceImpl(StoreManager storeManager,
-      InMemoryRepositoryServiceImpl repSvc, InMemoryNavigationServiceImpl navSvc) {
-    fStoreManager = storeManager;
-    fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
-    fNavigationService = navSvc;
-    fRepositoryService = repSvc;
-  }
-
-  public ObjectList getContentChanges(CallContext context, String repositoryId,
-      Holder<String> changeLogToken, Boolean includeProperties, String filter,
-      Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension,
-      ObjectInfoHolder objectInfos) {
-    // dummy implementation using hard coded values
-
-    try {
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
-      String rootFolderId = rep.getRootFolderId();
-
-      ObjectListImpl objList = new ObjectListImpl();
-      List<ObjectInFolderContainer> tempRes = fNavigationService.getDescendants(context,
-          repositoryId, rootFolderId, BigInteger.valueOf(3), filter, false,
-          IncludeRelationships.NONE, null, false, extension, null);
-
-      // convert ObjectInFolderContainerList to objectList
-      List<ObjectData> lod = new ArrayList<ObjectData>();
-      for (ObjectInFolderContainer obj : tempRes) {
-        convertList(lod, obj);
-      }
-      objList.setObjects(lod);
-      objList.setNumItems(BigInteger.valueOf(lod.size()));
-
-      // To be able to provide all Atom links in the response we need additional information:
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, null, objectInfos, objList);
-      return objList;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  private void convertList(List<ObjectData> lod, ObjectInFolderContainer obj) {
-    lod.add(obj.getObject().getObject());
-    // add dummy event info
-    ObjectData oif = obj.getObject().getObject();
-    ObjectDataImpl oifImpl = (ObjectDataImpl) oif;
-    ChangeEventInfoDataImpl changeEventInfo = new ChangeEventInfoDataImpl();
-    changeEventInfo.setChangeType(ChangeType.UPDATED);
-    changeEventInfo.setChangeTime(new GregorianCalendar());
-    oifImpl.setChangeEventInfo(changeEventInfo);
-    if (null != obj.getChildren()) {
-      for (ObjectInFolderContainer oifc : obj.getChildren()) {
-        convertList(lod, oifc);
-      }
-    }
-  }
-
-  public ObjectList query(CallContext context, String repositoryId, String statement,
-      Boolean searchAllVersions, Boolean includeAllowableActions,
-      IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems,
-      BigInteger skipCount, ExtensionsData extension) {
-    // dummy implementation using hard coded values
-
-    try {
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      // use descendants of root folder as result
-      RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
-      String rootFolderId = rep.getRootFolderId();
-      ObjectListImpl objList = new ObjectListImpl();
-      List<ObjectInFolderContainer> tempRes = fNavigationService.getDescendants(context,
-          repositoryId, rootFolderId, BigInteger.valueOf(3), "*", includeAllowableActions,
-          includeRelationships, renditionFilter, false, extension, null);
-
-      // convert ObjectInFolderContainerList to objectList
-      List<ObjectData> lod = new ArrayList<ObjectData>();
-      for (ObjectInFolderContainer obj : tempRes) {
-        convertList(lod, obj);
-      }
-      objList.setObjects(lod);
-      objList.setNumItems(BigInteger.valueOf(lod.size()));
-
-      return objList;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
+	private StoreManager fStoreManager;
+	AtomLinkInfoProvider fAtomLinkProvider;
+	InMemoryNavigationServiceImpl fNavigationService; // real implementation of
+														// the service
+	InMemoryRepositoryServiceImpl fRepositoryService;
+
+	public InMemoryDiscoveryServiceImpl(StoreManager storeManager, InMemoryRepositoryServiceImpl repSvc,
+			InMemoryNavigationServiceImpl navSvc) {
+		fStoreManager = storeManager;
+		fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
+		fNavigationService = navSvc;
+		fRepositoryService = repSvc;
+	}
+
+	public ObjectList getContentChanges(CallContext context, String repositoryId, Holder<String> changeLogToken,
+			Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeAcl,
+			BigInteger maxItems, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+		// dummy implementation using hard coded values
+
+		try {
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
+			String rootFolderId = rep.getRootFolderId();
+
+			ObjectListImpl objList = new ObjectListImpl();
+			List<ObjectInFolderContainer> tempRes = fNavigationService.getDescendants(context, repositoryId,
+					rootFolderId, BigInteger.valueOf(3), filter, false, IncludeRelationships.NONE, null, false,
+					extension, null);
+
+			// convert ObjectInFolderContainerList to objectList
+			List<ObjectData> lod = new ArrayList<ObjectData>();
+			for (ObjectInFolderContainer obj : tempRes) {
+				convertList(lod, obj);
+			}
+			objList.setObjects(lod);
+			objList.setNumItems(BigInteger.valueOf(lod.size()));
+
+			// To be able to provide all Atom links in the response we need
+			// additional information:
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, null, objectInfos, objList);
+			return objList;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	private void convertList(List<ObjectData> lod, ObjectInFolderContainer obj) {
+		lod.add(obj.getObject().getObject());
+		// add dummy event info
+		ObjectData oif = obj.getObject().getObject();
+		ObjectDataImpl oifImpl = (ObjectDataImpl) oif;
+		ChangeEventInfoDataImpl changeEventInfo = new ChangeEventInfoDataImpl();
+		changeEventInfo.setChangeType(ChangeType.UPDATED);
+		changeEventInfo.setChangeTime(new GregorianCalendar());
+		oifImpl.setChangeEventInfo(changeEventInfo);
+		if (null != obj.getChildren()) {
+			for (ObjectInFolderContainer oifc : obj.getChildren()) {
+				convertList(lod, oifc);
+			}
+		}
+	}
+
+	public ObjectList query(CallContext context, String repositoryId, String statement, Boolean searchAllVersions,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+		// dummy implementation using hard coded values
+
+		try {
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			// use descendants of root folder as result
+			RepositoryInfo rep = fRepositoryService.getRepositoryInfo(context, repositoryId, null);
+			String rootFolderId = rep.getRootFolderId();
+			ObjectListImpl objList = new ObjectListImpl();
+			List<ObjectInFolderContainer> tempRes = fNavigationService.getDescendants(context, repositoryId,
+					rootFolderId, BigInteger.valueOf(3), "*", includeAllowableActions, includeRelationships,
+					renditionFilter, false, extension, null);
+
+			// convert ObjectInFolderContainerList to objectList
+			List<ObjectData> lod = new ArrayList<ObjectData>();
+			for (ObjectInFolderContainer obj : tempRes) {
+				convertList(lod, obj);
+			}
+			objList.setObjects(lod);
+			objList.setNumItems(BigInteger.valueOf(lod.size()));
+
+			return objList;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryMultiFilingServiceImpl.java Fri Apr 16 14:00:23 2010
@@ -35,106 +35,106 @@ import org.apache.chemistry.opencmis.ser
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class InMemoryMultiFilingServiceImpl extends AbstractServiceImpl implements
-    CmisMultiFilingService {
+public class InMemoryMultiFilingServiceImpl extends AbstractServiceImpl implements CmisMultiFilingService {
 
-  private static final Log LOG = LogFactory.getLog(InMemoryMultiFilingServiceImpl.class.getName());
+	private static final Log LOG = LogFactory.getLog(InMemoryMultiFilingServiceImpl.class.getName());
 
-  AtomLinkInfoProvider fAtomLinkProvider;
+	AtomLinkInfoProvider fAtomLinkProvider;
 
-  public InMemoryMultiFilingServiceImpl(StoreManager storeMgr) {
-    super(storeMgr);
-    fAtomLinkProvider = new AtomLinkInfoProvider(storeMgr);
-  }
-
-  public ObjectData addObjectToFolder(CallContext context, String repositoryId, String objectId,
-      String folderId, Boolean allVersions, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("Begin addObjectToFolder()");
-
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      StoredObject[] so2 = checkParams(repositoryId, objectId, folderId);
-      if (allVersions != null && allVersions.booleanValue() == false)
-        throw new CmisNotSupportedException(
-            "Cannot add object to folder, version specific filing is not supported.");
-      StoredObject so = so2[0];
-      StoredObject folder = so2[1];
-      checkObjects(so, folder);
-
-      Folder newParent = (Folder) folder;
-      MultiFiling obj = (MultiFiling) so;
-      obj.addParent(newParent);
-
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
-
-      ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-          IncludeRelationships.NONE, null, false, false, extension);
-
-      LOG.debug("End addObjectToFolder()");
-      return od;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  public ObjectData removeObjectFromFolder(CallContext context, String repositoryId,
-      String objectId, String folderId, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("Begin removeObjectFromFolder()");
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      StoredObject so = checkStandardParameters(repositoryId, objectId);
-      ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-      StoredObject folder = checkExistingObjectId(objectStore, folderId);
-
-      checkObjects(so, folder);
-      Folder parent = (Folder) folder;
-      MultiFiling obj = (MultiFiling) so;
-      obj.removeParent(parent);
-
-      // To be able to provide all Atom links in the response we need additional information:
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
-
-      ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
-          IncludeRelationships.NONE, null, false, false, extension);
-
-      LOG.debug("End removeObjectFromFolder()");
-
-      return od;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  private StoredObject[] checkParams(String repositoryId, String objectId, String folderId) {
-    StoredObject[] so = new StoredObject[2];
-    so[0] = checkStandardParameters(repositoryId, objectId);
-    ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
-    so[1] = checkExistingObjectId(objectStore, folderId);
-    return so;
-  }
-
-  private void checkObjects(StoredObject so, StoredObject folder) {
-    if (!(so instanceof MultiFiling))
-      throw new CmisConstraintException("Cannot add object to folder, object id " + so.getId()
-          + " is not a multi-filed object.");
-
-    if ((so instanceof Folder))
-      throw new CmisConstraintException("Cannot add object to folder, object id " + folder.getId()
-          + " is a folder and folders are not multi-filed.");
-
-    if (!(folder instanceof Folder))
-      throw new CmisConstraintException("Cannot add object to folder, folder id " + folder.getId()
-          + " does not refer to a folder.");
-  }
+	public InMemoryMultiFilingServiceImpl(StoreManager storeMgr) {
+		super(storeMgr);
+		fAtomLinkProvider = new AtomLinkInfoProvider(storeMgr);
+	}
+
+	public ObjectData addObjectToFolder(CallContext context, String repositoryId, String objectId, String folderId,
+			Boolean allVersions, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("Begin addObjectToFolder()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			StoredObject[] so2 = checkParams(repositoryId, objectId, folderId);
+			if (allVersions != null && allVersions.booleanValue() == false)
+				throw new CmisNotSupportedException(
+						"Cannot add object to folder, version specific filing is not supported.");
+			StoredObject so = so2[0];
+			StoredObject folder = so2[1];
+			checkObjects(so, folder);
+
+			Folder newParent = (Folder) folder;
+			MultiFiling obj = (MultiFiling) so;
+			obj.addParent(newParent);
+
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
+
+			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
+					IncludeRelationships.NONE, null, false, false, extension);
+
+			LOG.debug("End addObjectToFolder()");
+			return od;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	public ObjectData removeObjectFromFolder(CallContext context, String repositoryId, String objectId,
+			String folderId, ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("Begin removeObjectFromFolder()");
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			StoredObject so = checkStandardParameters(repositoryId, objectId);
+			ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+			StoredObject folder = checkExistingObjectId(objectStore, folderId);
+
+			checkObjects(so, folder);
+			Folder parent = (Folder) folder;
+			MultiFiling obj = (MultiFiling) so;
+			obj.removeParent(parent);
+
+			// To be able to provide all Atom links in the response we need
+			// additional information:
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, folder, objectInfos);
+
+			ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, so, null, false,
+					IncludeRelationships.NONE, null, false, false, extension);
+
+			LOG.debug("End removeObjectFromFolder()");
+
+			return od;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	private StoredObject[] checkParams(String repositoryId, String objectId, String folderId) {
+		StoredObject[] so = new StoredObject[2];
+		so[0] = checkStandardParameters(repositoryId, objectId);
+		ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
+		so[1] = checkExistingObjectId(objectStore, folderId);
+		return so;
+	}
+
+	private void checkObjects(StoredObject so, StoredObject folder) {
+		if (!(so instanceof MultiFiling))
+			throw new CmisConstraintException("Cannot add object to folder, object id " + so.getId()
+					+ " is not a multi-filed object.");
+
+		if ((so instanceof Folder))
+			throw new CmisConstraintException("Cannot add object to folder, object id " + folder.getId()
+					+ " is a folder and folders are not multi-filed.");
+
+		if (!(folder instanceof Folder))
+			throw new CmisConstraintException("Cannot add object to folder, folder id " + folder.getId()
+					+ " does not refer to a folder.");
+	}
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java?rev=934878&r1=934877&r2=934878&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryNavigationServiceImpl.java Fri Apr 16 14:00:23 2010
@@ -61,388 +61,389 @@ import org.apache.chemistry.opencmis.ser
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class InMemoryNavigationServiceImpl extends AbstractServiceImpl implements
-    CmisNavigationService {
+public class InMemoryNavigationServiceImpl extends AbstractServiceImpl implements CmisNavigationService {
 
-  private static Log LOG = LogFactory.getLog(InMemoryNavigationServiceImpl.class);
+	private static Log LOG = LogFactory.getLog(InMemoryNavigationServiceImpl.class);
 
-  AtomLinkInfoProvider fAtomLinkProvider;
+	AtomLinkInfoProvider fAtomLinkProvider;
 
-  public InMemoryNavigationServiceImpl(StoreManager storeManager) {
-    super(storeManager);
-    fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
-  }
-
-  public ObjectList getCheckedOutDocs(CallContext context, String repositoryId, String folderId,
-      String filter, String orderBy, Boolean includeAllowableActions,
-      IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems,
-      BigInteger skipCount, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      ObjectListImpl res = new ObjectListImpl();
-      List<ObjectData> odList = new ArrayList<ObjectData>();
-
-      LOG.debug("start getCheckedOutDocs()");
-      if (null != folderId)
-        checkStandardParameters(repositoryId, folderId);
-      else
-        checkRepositoryId(repositoryId);
-
-      if (null == folderId) {
-        List<VersionedDocument> checkedOuts = fStoreManager.getObjectStore(repositoryId)
-            .getCheckedOutDocuments(orderBy);
-        for (VersionedDocument checkedOut : checkedOuts) {
-          ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, checkedOut, filter,
-              includeAllowableActions, includeRelationships, renditionFilter, false, false,
-              extension);
-          fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, checkedOut, objectInfos);
-          odList.add(od);
-        }
-      }
-      else {
-        ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
-            includeAllowableActions, includeRelationships, renditionFilter, false, -1, -1, false,
-            objectInfos);
-        for (ObjectInFolderData child : children.getObjects()) {
-          ObjectData obj = child.getObject();
-          StoredObject so = fStoreManager.getObjectStore(repositoryId).getObjectById(obj.getId());
-          LOG.info("Checked out: children:" + obj.getId());
-          if (so instanceof DocumentVersion
-              && ((DocumentVersion) so).getParentDocument().isCheckedOut()) {
-            odList.add(obj);
-            fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-          }
-        }
-      }
-      res.setObjects(odList);
-      res.setNumItems(BigInteger.valueOf(odList.size()));
-
-      LOG.debug("end getCheckedOutDocs()");
-      return res;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  public ObjectInFolderList getChildren(CallContext context, String repositoryId, String folderId,
-      String filter, String orderBy, Boolean includeAllowableActions,
-      IncludeRelationships includeRelationships, String renditionFilter,
-      Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount,
-      ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("start getChildren()");
-
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      checkStandardParameters(repositoryId, folderId);
-
-      int maxItemsInt = maxItems == null ? -1 : maxItems.intValue();
-      int skipCountInt = skipCount == null ? -1 : skipCount.intValue();
-      ObjectInFolderList res = getChildrenIntern(repositoryId, folderId, filter, orderBy,
-          includeAllowableActions, includeRelationships, renditionFilter, includePathSegment,
-          maxItemsInt, skipCountInt, false, objectInfos);
-      LOG.debug("stop getChildren()");
-      return res;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  public List<ObjectInFolderContainer> getDescendants(CallContext context, String repositoryId,
-      String folderId, BigInteger depth, String filter, Boolean includeAllowableActions,
-      IncludeRelationships includeRelationships, String renditionFilter,
-      Boolean includePathSegment, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("start getDescendants()");
-
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      checkStandardParameters(repositoryId, folderId);
-
-      int levels;
-      if (depth == null)
-        levels = 2; // one of the recommended defaults (should it be -1?)
-      else if (depth.intValue() == 0)
-        throw new CmisInvalidArgumentException("A zero depth is not allowed for getDescendants().");
-      else
-        levels = depth.intValue();
-
-      int level = 0;
-      List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
-          includeAllowableActions, includeRelationships, renditionFilter, includePathSegment,
-          level, levels, false, objectInfos);
-
-      LOG.debug("stop getDescendants()");
-      return result;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  public ObjectData getFolderParent(CallContext context, String repositoryId, String folderId,
-      String filter, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("start getFolderParent()");
-
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      StoredObject so = checkStandardParameters(repositoryId, folderId);
-
-      Folder folder = null;
-      if (so instanceof Folder)
-        folder = (Folder) so;
-      else
-        throw new CmisInvalidArgumentException(
-            "Can't get folder parent, id does not refer to a folder: " + folderId);
-
-      ObjectData res = getFolderParentIntern(repositoryId, folder, filter, objectInfos);
-
-      // To be able to provide all Atom links in the response we need additional information:
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-      LOG.debug("stop getFolderParent()");
-      return res;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  public List<ObjectInFolderContainer> getFolderTree(CallContext context, String repositoryId,
-      String folderId, BigInteger depth, String filter, Boolean includeAllowableActions,
-      IncludeRelationships includeRelationships, String renditionFilter,
-      Boolean includePathSegment, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("start getFolderTree()");
-
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      checkStandardParameters(repositoryId, folderId);
-
-      if (depth != null && depth.intValue() == 0)
-        throw new CmisInvalidArgumentException("A zero depth is not allowed for getFolderTree().");
-
-      int levels = depth == null ? 2 : depth.intValue();
-      int level = 0;
-      List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
-          includeAllowableActions, includeRelationships, renditionFilter, includePathSegment,
-          level, levels, true, objectInfos);
-
-      LOG.debug("stop getFolderTree()");
-      return result;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  public List<ObjectParentData> getObjectParents(CallContext context, String repositoryId,
-      String objectId, String filter, Boolean includeAllowableActions,
-      IncludeRelationships includeRelationships, String renditionFilter,
-      Boolean includeRelativePathSegment, ExtensionsData extension, ObjectInfoHolder objectInfos) {
-
-    try {
-      LOG.debug("start getObjectParents()");
-
-      // Attach the CallContext to a thread local context that can be accessed from everywhere
-      RuntimeContext.attachCfg(context);
-
-      StoredObject so = checkStandardParameters(repositoryId, objectId);
-
-      // for now we have only folders that have a parent and the in-memory provider only has one
-      // parent for each object (no multi-filing)
-      List<ObjectParentData> result = null;
-
-      Filing spo = null;
-      if (so instanceof Filing)
-        spo = (Filing) so;
-      else
-        throw new CmisInvalidArgumentException(
-            "Can't get object parent, id does not refer to a folder or document: " + objectId);
-
-      result = getObjectParentsIntern(repositoryId, spo, filter, objectInfos);
-
-      // To be able to provide all Atom links in the response we need additional information:
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-
-      LOG.debug("stop getObjectParents()");
-      return result;
-    }
-    finally {
-      RuntimeContext.remove();
-    }
-  }
-
-  // private helpers
-
-  private ObjectInFolderList getChildrenIntern(String repositoryId, String folderId, String filter,
-      String orderBy, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
-      String renditionFilter, Boolean includePathSegments, int maxItems, int skipCount,
-      boolean folderOnly, ObjectInfoHolder objectInfos) {
-
-    ObjectInFolderListImpl result = new ObjectInFolderListImpl();
-    List<ObjectInFolderData> folderList = new ArrayList<ObjectInFolderData>();
-    ObjectStore fs = fStoreManager.getObjectStore(repositoryId);
-    StoredObject so = fs.getObjectById(folderId);
-    Folder folder = null;
-
-    if (so == null)
-      throw new CmisObjectNotFoundException("Unknown object id: " + folderId);
-
-    if (so instanceof Folder)
-      folder = (Folder) so;
-    else
-      return null; // it is a document and has no children
-
-    List<? extends StoredObject> children = folderOnly ? folder.getFolderChildren(maxItems,
-        skipCount) : folder.getChildren(maxItems, skipCount);
-
-    List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-
-    for (StoredObject spo : children) {
-      ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
-      ObjectDataImpl objectData = new ObjectDataImpl();
-      if (includePathSegments != null && includePathSegments)
-        oifd.setPathSegment(spo.getName());
-      if (includeAllowableActions != null && includeAllowableActions) {
-        AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(fs, spo);
-        objectData.setAllowableActions(allowableActions);
-      }
-      if (includeRelationships != null && includeRelationships != IncludeRelationships.NONE) {
-        objectData.setRelationships(null /* f.getRelationships() */);
-      }
-      if (renditionFilter != null && renditionFilter.length() > 0) {
-        objectData.setRelationships(null /* f.getRenditions(renditionFilter) */);
-      }
-
-      Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, spo,
-          fStoreManager, requestedIds);
-      objectData.setProperties(props);
-
-      oifd.setObject(objectData);
-      folderList.add(oifd);
-      // add additional information for Atom
-      fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, spo, objectInfos);
-
-    }
-    result.setObjects(folderList);
-    fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
-    return result;
-  }
-
-  private List<ObjectInFolderContainer> getDescendantsIntern(String repositoryId, String folderId,
-      String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
-      String renditionFilter, Boolean includePathSegments, int level, int maxLevels,
-      boolean folderOnly, ObjectInfoHolder objectInfos) {
-
-    // log.info("getDescendantsIntern: " + folderId + ", in level " + level
-    // + ", max levels " + maxLevels);
-
-    List<ObjectInFolderContainer> childrenOfFolderId = null;
-    if (maxLevels == -1 || level < maxLevels) {
-      String orderBy = PropertyIds.NAME;
-      ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
-          includeAllowableActions, includeRelationships, renditionFilter, includePathSegments,
-          1000, 0, folderOnly, objectInfos);
-
-      childrenOfFolderId = new ArrayList<ObjectInFolderContainer>();
-      if (null != children) {
-
-        for (ObjectInFolderData child : children.getObjects()) {
-          ObjectInFolderContainerImpl oifc = new ObjectInFolderContainerImpl();
-          String childId = child.getObject().getId();
-          List<ObjectInFolderContainer> subChildren = getDescendantsIntern(repositoryId, childId,
-              filter, includeAllowableActions, includeRelationships, renditionFilter,
-              includePathSegments, level + 1, maxLevels, folderOnly, objectInfos);
-
-          oifc.setObject(child);
-          if (null != subChildren)
-            oifc.setChildren(subChildren);
-          childrenOfFolderId.add(oifc);
-        }
-      }
-    }
-    return childrenOfFolderId;
-  }
-
-  private List<ObjectParentData> getObjectParentsIntern(String repositoryId, Filing sop,
-      String filter, ObjectInfoHolder objectInfos) {
-
-    List<ObjectParentData> result = null;
-    if (sop instanceof SingleFiling) {
-      ObjectData parent = getFolderParentIntern(repositoryId, (SingleFiling) sop, filter,
-          objectInfos);
-      if (null != parent) {
-        ObjectParentDataImpl parentData = new ObjectParentDataImpl();
-        parentData.setObject(parent);
-        String path = ((SingleFiling) sop).getPath();
-        int beginIndex = path.lastIndexOf(Filing.PATH_SEPARATOR) + 1; // Note: if / not found
-        // results in 0
-        String relPathSeg = path.substring(beginIndex, path.length());
-        parentData.setRelativePathSegment(relPathSeg);
-        result = Collections.singletonList((ObjectParentData) parentData);
-      }
-      else
-        result = Collections.emptyList();
-    }
-    else if (sop instanceof MultiFiling) {
-      result = new ArrayList<ObjectParentData>();
-      MultiFiling multiParentObj = (MultiFiling) sop;
-      List<Folder> parents = multiParentObj.getParents();
-      if (null != parents)
-        for (Folder parent : parents) {
-          ObjectParentDataImpl parentData = new ObjectParentDataImpl();
-          ObjectDataImpl objData = new ObjectDataImpl();
-          copyFilteredProperties(repositoryId, parent, filter, objData);
-          parentData.setObject(objData);
-          parentData.setRelativePathSegment(multiParentObj.getPathSegment());
-          result.add(parentData);
-          fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, parent, objectInfos);
-        }
-    }
-    return result;
-  }
-
-  private ObjectData getFolderParentIntern(String repositoryId, SingleFiling sop, String filter,
-      ObjectInfoHolder objectInfos) {
-
-    ObjectDataImpl parent = new ObjectDataImpl();
-
-    Folder parentFolder = sop.getParent();
-
-    if (null == parentFolder) {
-      if (sop instanceof Children) // a folder without a parent
-        throw new CmisInvalidArgumentException("Cannot get parent of a root folder");
-      else
-        return null; // an unfiled document
-    }
-
-    copyFilteredProperties(repositoryId, parentFolder, filter, parent);
-    fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, parentFolder, objectInfos);
-
-    return parent;
-  }
-
-  void copyFilteredProperties(String repositoryId, StoredObject so, String filter,
-      ObjectDataImpl objData) {
-    List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
-    Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, so,
-        fStoreManager, requestedIds);
-    objData.setProperties(props);
-  }
+	public InMemoryNavigationServiceImpl(StoreManager storeManager) {
+		super(storeManager);
+		fAtomLinkProvider = new AtomLinkInfoProvider(fStoreManager);
+	}
+
+	public ObjectList getCheckedOutDocs(CallContext context, String repositoryId, String folderId, String filter,
+			String orderBy, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+			String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension,
+			ObjectInfoHolder objectInfos) {
+
+		try {
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			ObjectListImpl res = new ObjectListImpl();
+			List<ObjectData> odList = new ArrayList<ObjectData>();
+
+			LOG.debug("start getCheckedOutDocs()");
+			if (null != folderId)
+				checkStandardParameters(repositoryId, folderId);
+			else
+				checkRepositoryId(repositoryId);
+
+			if (null == folderId) {
+				List<VersionedDocument> checkedOuts = fStoreManager.getObjectStore(repositoryId)
+						.getCheckedOutDocuments(orderBy);
+				for (VersionedDocument checkedOut : checkedOuts) {
+					ObjectData od = PropertyCreationHelper.getObjectData(fStoreManager, checkedOut, filter,
+							includeAllowableActions, includeRelationships, renditionFilter, false, false, extension);
+					fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, checkedOut, objectInfos);
+					odList.add(od);
+				}
+			} else {
+				ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
+						includeAllowableActions, includeRelationships, renditionFilter, false, -1, -1, false,
+						objectInfos);
+				for (ObjectInFolderData child : children.getObjects()) {
+					ObjectData obj = child.getObject();
+					StoredObject so = fStoreManager.getObjectStore(repositoryId).getObjectById(obj.getId());
+					LOG.info("Checked out: children:" + obj.getId());
+					if (so instanceof DocumentVersion && ((DocumentVersion) so).getParentDocument().isCheckedOut()) {
+						odList.add(obj);
+						fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+					}
+				}
+			}
+			res.setObjects(odList);
+			res.setNumItems(BigInteger.valueOf(odList.size()));
+
+			LOG.debug("end getCheckedOutDocs()");
+			return res;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	public ObjectInFolderList getChildren(CallContext context, String repositoryId, String folderId, String filter,
+			String orderBy, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+			String renditionFilter, Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount,
+			ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("start getChildren()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			checkStandardParameters(repositoryId, folderId);
+
+			int maxItemsInt = maxItems == null ? -1 : maxItems.intValue();
+			int skipCountInt = skipCount == null ? -1 : skipCount.intValue();
+			ObjectInFolderList res = getChildrenIntern(repositoryId, folderId, filter, orderBy,
+					includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItemsInt,
+					skipCountInt, false, objectInfos);
+			LOG.debug("stop getChildren()");
+			return res;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	public List<ObjectInFolderContainer> getDescendants(CallContext context, String repositoryId, String folderId,
+			BigInteger depth, String filter, Boolean includeAllowableActions,
+			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment,
+			ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("start getDescendants()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			checkStandardParameters(repositoryId, folderId);
+
+			int levels;
+			if (depth == null)
+				levels = 2; // one of the recommended defaults (should it be
+							// -1?)
+			else if (depth.intValue() == 0)
+				throw new CmisInvalidArgumentException("A zero depth is not allowed for getDescendants().");
+			else
+				levels = depth.intValue();
+
+			int level = 0;
+			List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
+					includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, level, levels,
+					false, objectInfos);
+
+			LOG.debug("stop getDescendants()");
+			return result;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	public ObjectData getFolderParent(CallContext context, String repositoryId, String folderId, String filter,
+			ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("start getFolderParent()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			StoredObject so = checkStandardParameters(repositoryId, folderId);
+
+			Folder folder = null;
+			if (so instanceof Folder)
+				folder = (Folder) so;
+			else
+				throw new CmisInvalidArgumentException("Can't get folder parent, id does not refer to a folder: "
+						+ folderId);
+
+			ObjectData res = getFolderParentIntern(repositoryId, folder, filter, objectInfos);
+
+			// To be able to provide all Atom links in the response we need
+			// additional information:
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+			LOG.debug("stop getFolderParent()");
+			return res;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	public List<ObjectInFolderContainer> getFolderTree(CallContext context, String repositoryId, String folderId,
+			BigInteger depth, String filter, Boolean includeAllowableActions,
+			IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment,
+			ExtensionsData extension, ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("start getFolderTree()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			checkStandardParameters(repositoryId, folderId);
+
+			if (depth != null && depth.intValue() == 0)
+				throw new CmisInvalidArgumentException("A zero depth is not allowed for getFolderTree().");
+
+			int levels = depth == null ? 2 : depth.intValue();
+			int level = 0;
+			List<ObjectInFolderContainer> result = getDescendantsIntern(repositoryId, folderId, filter,
+					includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, level, levels,
+					true, objectInfos);
+
+			LOG.debug("stop getFolderTree()");
+			return result;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	public List<ObjectParentData> getObjectParents(CallContext context, String repositoryId, String objectId,
+			String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships,
+			String renditionFilter, Boolean includeRelativePathSegment, ExtensionsData extension,
+			ObjectInfoHolder objectInfos) {
+
+		try {
+			LOG.debug("start getObjectParents()");
+
+			// Attach the CallContext to a thread local context that can be
+			// accessed from everywhere
+			RuntimeContext.attachCfg(context);
+
+			StoredObject so = checkStandardParameters(repositoryId, objectId);
+
+			// for now we have only folders that have a parent and the in-memory
+			// provider only has one
+			// parent for each object (no multi-filing)
+			List<ObjectParentData> result = null;
+
+			Filing spo = null;
+			if (so instanceof Filing)
+				spo = (Filing) so;
+			else
+				throw new CmisInvalidArgumentException(
+						"Can't get object parent, id does not refer to a folder or document: " + objectId);
+
+			result = getObjectParentsIntern(repositoryId, spo, filter, objectInfos);
+
+			// To be able to provide all Atom links in the response we need
+			// additional information:
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+
+			LOG.debug("stop getObjectParents()");
+			return result;
+		} finally {
+			RuntimeContext.remove();
+		}
+	}
+
+	// private helpers
+
+	private ObjectInFolderList getChildrenIntern(String repositoryId, String folderId, String filter, String orderBy,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			Boolean includePathSegments, int maxItems, int skipCount, boolean folderOnly, ObjectInfoHolder objectInfos) {
+
+		ObjectInFolderListImpl result = new ObjectInFolderListImpl();
+		List<ObjectInFolderData> folderList = new ArrayList<ObjectInFolderData>();
+		ObjectStore fs = fStoreManager.getObjectStore(repositoryId);
+		StoredObject so = fs.getObjectById(folderId);
+		Folder folder = null;
+
+		if (so == null)
+			throw new CmisObjectNotFoundException("Unknown object id: " + folderId);
+
+		if (so instanceof Folder)
+			folder = (Folder) so;
+		else
+			return null; // it is a document and has no children
+
+		List<? extends StoredObject> children = folderOnly ? folder.getFolderChildren(maxItems, skipCount) : folder
+				.getChildren(maxItems, skipCount);
+
+		List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+
+		for (StoredObject spo : children) {
+			ObjectInFolderDataImpl oifd = new ObjectInFolderDataImpl();
+			ObjectDataImpl objectData = new ObjectDataImpl();
+			if (includePathSegments != null && includePathSegments)
+				oifd.setPathSegment(spo.getName());
+			if (includeAllowableActions != null && includeAllowableActions) {
+				AllowableActions allowableActions = DataObjectCreator.fillAllowableActions(fs, spo);
+				objectData.setAllowableActions(allowableActions);
+			}
+			if (includeRelationships != null && includeRelationships != IncludeRelationships.NONE) {
+				objectData.setRelationships(null /* f.getRelationships() */);
+			}
+			if (renditionFilter != null && renditionFilter.length() > 0) {
+				objectData.setRelationships(null /*
+												 * f.getRenditions(renditionFilter
+												 * )
+												 */);
+			}
+
+			Properties props = PropertyCreationHelper.getPropertiesFromObject(repositoryId, spo, fStoreManager,
+					requestedIds);
+			objectData.setProperties(props);
+
+			oifd.setObject(objectData);
+			folderList.add(oifd);
+			// add additional information for Atom
+			fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, spo, objectInfos);
+
+		}
+		result.setObjects(folderList);
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, so, objectInfos);
+		return result;
+	}
+
+	private List<ObjectInFolderContainer> getDescendantsIntern(String repositoryId, String folderId, String filter,
+			Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+			Boolean includePathSegments, int level, int maxLevels, boolean folderOnly, ObjectInfoHolder objectInfos) {
+
+		// log.info("getDescendantsIntern: " + folderId + ", in level " + level
+		// + ", max levels " + maxLevels);
+
+		List<ObjectInFolderContainer> childrenOfFolderId = null;
+		if (maxLevels == -1 || level < maxLevels) {
+			String orderBy = PropertyIds.NAME;
+			ObjectInFolderList children = getChildrenIntern(repositoryId, folderId, filter, orderBy,
+					includeAllowableActions, includeRelationships, renditionFilter, includePathSegments, 1000, 0,
+					folderOnly, objectInfos);
+
+			childrenOfFolderId = new ArrayList<ObjectInFolderContainer>();
+			if (null != children) {
+
+				for (ObjectInFolderData child : children.getObjects()) {
+					ObjectInFolderContainerImpl oifc = new ObjectInFolderContainerImpl();
+					String childId = child.getObject().getId();
+					List<ObjectInFolderContainer> subChildren = getDescendantsIntern(repositoryId, childId, filter,
+							includeAllowableActions, includeRelationships, renditionFilter, includePathSegments,
+							level + 1, maxLevels, folderOnly, objectInfos);
+
+					oifc.setObject(child);
+					if (null != subChildren)
+						oifc.setChildren(subChildren);
+					childrenOfFolderId.add(oifc);
+				}
+			}
+		}
+		return childrenOfFolderId;
+	}
+
+	private List<ObjectParentData> getObjectParentsIntern(String repositoryId, Filing sop, String filter,
+			ObjectInfoHolder objectInfos) {
+
+		List<ObjectParentData> result = null;
+		if (sop instanceof SingleFiling) {
+			ObjectData parent = getFolderParentIntern(repositoryId, (SingleFiling) sop, filter, objectInfos);
+			if (null != parent) {
+				ObjectParentDataImpl parentData = new ObjectParentDataImpl();
+				parentData.setObject(parent);
+				String path = ((SingleFiling) sop).getPath();
+				int beginIndex = path.lastIndexOf(Filing.PATH_SEPARATOR) + 1; // Note
+																				// :
+																				// if
+																				// /
+																				// not
+																				// found
+				// results in 0
+				String relPathSeg = path.substring(beginIndex, path.length());
+				parentData.setRelativePathSegment(relPathSeg);
+				result = Collections.singletonList((ObjectParentData) parentData);
+			} else
+				result = Collections.emptyList();
+		} else if (sop instanceof MultiFiling) {
+			result = new ArrayList<ObjectParentData>();
+			MultiFiling multiParentObj = (MultiFiling) sop;
+			List<Folder> parents = multiParentObj.getParents();
+			if (null != parents)
+				for (Folder parent : parents) {
+					ObjectParentDataImpl parentData = new ObjectParentDataImpl();
+					ObjectDataImpl objData = new ObjectDataImpl();
+					copyFilteredProperties(repositoryId, parent, filter, objData);
+					parentData.setObject(objData);
+					parentData.setRelativePathSegment(multiParentObj.getPathSegment());
+					result.add(parentData);
+					fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, parent, objectInfos);
+				}
+		}
+		return result;
+	}
+
+	private ObjectData getFolderParentIntern(String repositoryId, SingleFiling sop, String filter,
+			ObjectInfoHolder objectInfos) {
+
+		ObjectDataImpl parent = new ObjectDataImpl();
+
+		Folder parentFolder = sop.getParent();
+
+		if (null == parentFolder) {
+			if (sop instanceof Children) // a folder without a parent
+				throw new CmisInvalidArgumentException("Cannot get parent of a root folder");
+			else
+				return null; // an unfiled document
+		}
+
+		copyFilteredProperties(repositoryId, parentFolder, filter, parent);
+		fAtomLinkProvider.fillInformationForAtomLinks(repositoryId, parentFolder, objectInfos);
+
+		return parent;
+	}
+
+	void copyFilteredProperties(String repositoryId, StoredObject so, String filter, ObjectDataImpl objData) {
+		List<String> requestedIds = FilterParser.getRequestedIdsFromFilter(filter);
+		Properties props = PropertyCreationHelper
+				.getPropertiesFromObject(repositoryId, so, fStoreManager, requestedIds);
+		objData.setProperties(props);
+	}
 
 }



Mime
View raw message