Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 59927 invoked from network); 16 Apr 2010 14:15:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Apr 2010 14:15:05 -0000 Received: (qmail 66293 invoked by uid 500); 16 Apr 2010 14:15:05 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 66266 invoked by uid 500); 16 Apr 2010 14:15:05 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 66258 invoked by uid 99); 16 Apr 2010 14:15:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 14:15:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 14:14:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CD9A72388C10; Fri, 16 Apr 2010 14:14:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r934896 [11/12] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/ chemistry-opencmis-server-bindings/src/main/java/org/apache/chem... Date: Fri, 16 Apr 2010 14:14:02 -0000 To: chemistry-commits@incubator.apache.org From: jens@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100416141403.CD9A72388C10@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/NavigationServiceWrapper.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/NavigationServiceWrapper.java?rev=934896&r1=934895&r2=934896&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/NavigationServiceWrapper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/NavigationServiceWrapper.java Fri Apr 16 14:14:00 2010 @@ -38,214 +38,210 @@ import org.apache.chemistry.opencmis.ser * @author Florian Müller * */ -public class NavigationServiceWrapper extends AbstractServiceWrapper implements - CmisNavigationService { +public class NavigationServiceWrapper extends AbstractServiceWrapper implements CmisNavigationService { - private CmisNavigationService fService; + private CmisNavigationService fService; - /** - * Constructor. - * - * @param service - * the real service object - * @param defaultMaxItems - * default value for maxItems parameters - * @param defaultDepth - * default value for depth parameters - */ - public NavigationServiceWrapper(CmisNavigationService service, BigInteger defaultMaxItems, - BigInteger defaultDepth) { - if (service == null) { - throw new IllegalArgumentException("Service must be set!"); - } - - fService = service; - setDefaultMaxItems(defaultMaxItems); - setDefaultDepth(defaultDepth); - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.server.spi.CmisNavigationService#getCheckedOutDocs(org.apache.opencmis. - * server.spi.CallContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, - * java.lang.Boolean, org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, - * java.math.BigInteger, java.math.BigInteger, org.apache.opencmis.commons.api.ExtensionsData, - * org.apache.opencmis.server.spi.ObjectInfoHolder) - */ - 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) { - checkRepositoryId(repositoryId); - includeAllowableActions = getDefaultFalse(includeAllowableActions); - includeRelationships = getDefault(includeRelationships); - renditionFilter = getDefaultRenditionFilter(renditionFilter); - maxItems = getMaxItems(maxItems); - skipCount = getSkipCount(skipCount); - - try { - return fService.getCheckedOutDocs(context, repositoryId, folderId, filter, orderBy, - includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, - extension, objectInfos); - } - catch (Exception e) { - throw createCmisException(e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.server.spi.CmisNavigationService#getChildren(org.apache.opencmis.server - * .spi.CallContext, java.lang.String, java.lang.String, java.lang.String, java.lang.String, - * java.lang.Boolean, org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, - * java.lang.Boolean, java.math.BigInteger, java.math.BigInteger, - * org.apache.opencmis.commons.api.ExtensionsData, - * org.apache.opencmis.server.spi.ObjectInfoHolder) - */ - 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) { - checkRepositoryId(repositoryId); - checkId("Folder Id", folderId); - includeAllowableActions = getDefaultFalse(includeAllowableActions); - includeRelationships = getDefault(includeRelationships); - renditionFilter = getDefaultRenditionFilter(renditionFilter); - includePathSegment = getDefaultFalse(includePathSegment); - maxItems = getMaxItems(maxItems); - skipCount = getSkipCount(skipCount); - - try { - return fService.getChildren(context, repositoryId, folderId, filter, orderBy, - includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, - maxItems, skipCount, extension, objectInfos); - } - catch (Exception e) { - throw createCmisException(e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.server.spi.CmisNavigationService#getDescendants(org.apache.opencmis.server - * .spi.CallContext, java.lang.String, java.lang.String, java.math.BigInteger, java.lang.String, - * java.lang.Boolean, org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, - * java.lang.Boolean, org.apache.opencmis.commons.api.ExtensionsData, - * org.apache.opencmis.server.spi.ObjectInfoHolder) - */ - public List getDescendants(CallContext context, String repositoryId, - String folderId, BigInteger depth, String filter, Boolean includeAllowableActions, - IncludeRelationships includeRelationships, String renditionFilter, - Boolean includePathSegment, ExtensionsData extension, ObjectInfoHolder objectInfos) { - checkRepositoryId(repositoryId); - checkId("Folder Id", folderId); - depth = getDepth(depth); - includeAllowableActions = getDefaultFalse(includeAllowableActions); - includeRelationships = getDefault(includeRelationships); - renditionFilter = getDefaultRenditionFilter(renditionFilter); - includePathSegment = getDefaultFalse(includePathSegment); - - try { - return fService.getDescendants(context, repositoryId, folderId, depth, filter, - includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, - extension, objectInfos); - } - catch (Exception e) { - throw createCmisException(e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.server.spi.CmisNavigationService#getFolderParent(org.apache.opencmis.server - * .spi.CallContext, java.lang.String, java.lang.String, java.lang.String, - * org.apache.opencmis.commons.api.ExtensionsData, - * org.apache.opencmis.server.spi.ObjectInfoHolder) - */ - public ObjectData getFolderParent(CallContext context, String repositoryId, String folderId, - String filter, ExtensionsData extension, ObjectInfoHolder objectInfos) { - checkRepositoryId(repositoryId); - checkId("Folder Id", folderId); - - try { - return fService.getFolderParent(context, repositoryId, folderId, filter, extension, - objectInfos); - } - catch (Exception e) { - throw createCmisException(e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.server.spi.CmisNavigationService#getFolderTree(org.apache.opencmis.server - * .spi.CallContext, java.lang.String, java.lang.String, java.math.BigInteger, java.lang.String, - * java.lang.Boolean, org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, - * java.lang.Boolean, org.apache.opencmis.commons.api.ExtensionsData, - * org.apache.opencmis.server.spi.ObjectInfoHolder) - */ - public List getFolderTree(CallContext context, String repositoryId, - String folderId, BigInteger depth, String filter, Boolean includeAllowableActions, - IncludeRelationships includeRelationships, String renditionFilter, - Boolean includePathSegment, ExtensionsData extension, ObjectInfoHolder objectInfos) { - checkRepositoryId(repositoryId); - checkId("Folder Id", folderId); - depth = getDepth(depth); - includeAllowableActions = getDefaultFalse(includeAllowableActions); - includeRelationships = getDefault(includeRelationships); - renditionFilter = getDefaultRenditionFilter(renditionFilter); - includePathSegment = getDefaultFalse(includePathSegment); - - try { - return fService.getFolderTree(context, repositoryId, folderId, depth, filter, - includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, - extension, objectInfos); - } - catch (Exception e) { - throw createCmisException(e); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.apache.opencmis.server.spi.CmisNavigationService#getObjectParents(org.apache.opencmis.server - * .spi.CallContext, java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, - * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, java.lang.Boolean, - * org.apache.opencmis.commons.api.ExtensionsData, - * org.apache.opencmis.server.spi.ObjectInfoHolder) - */ - public List getObjectParents(CallContext context, String repositoryId, - String objectId, String filter, Boolean includeAllowableActions, - IncludeRelationships includeRelationships, String renditionFilter, - Boolean includeRelativePathSegment, ExtensionsData extension, ObjectInfoHolder objectInfos) { - checkRepositoryId(repositoryId); - checkId("Object Id", objectId); - includeAllowableActions = getDefaultFalse(includeAllowableActions); - includeRelationships = getDefault(includeRelationships); - renditionFilter = getDefaultRenditionFilter(renditionFilter); - includeRelativePathSegment = getDefaultFalse(includeRelativePathSegment); - - try { - return fService.getObjectParents(context, repositoryId, objectId, filter, - includeAllowableActions, includeRelationships, renditionFilter, - includeRelativePathSegment, extension, objectInfos); - } - catch (Exception e) { - throw createCmisException(e); - } - } + /** + * Constructor. + * + * @param service + * the real service object + * @param defaultMaxItems + * default value for maxItems parameters + * @param defaultDepth + * default value for depth parameters + */ + public NavigationServiceWrapper(CmisNavigationService service, BigInteger defaultMaxItems, BigInteger defaultDepth) { + if (service == null) { + throw new IllegalArgumentException("Service must be set!"); + } + + fService = service; + setDefaultMaxItems(defaultMaxItems); + setDefaultDepth(defaultDepth); + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.server.spi.CmisNavigationService#getCheckedOutDocs + * (org.apache.opencmis. server.spi.CallContext, java.lang.String, + * java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, + * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, + * java.math.BigInteger, java.math.BigInteger, + * org.apache.opencmis.commons.api.ExtensionsData, + * org.apache.opencmis.server.spi.ObjectInfoHolder) + */ + 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) { + checkRepositoryId(repositoryId); + includeAllowableActions = getDefaultFalse(includeAllowableActions); + includeRelationships = getDefault(includeRelationships); + renditionFilter = getDefaultRenditionFilter(renditionFilter); + maxItems = getMaxItems(maxItems); + skipCount = getSkipCount(skipCount); + + try { + return fService.getCheckedOutDocs(context, repositoryId, folderId, filter, orderBy, + includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, extension, + objectInfos); + } catch (Exception e) { + throw createCmisException(e); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.server.spi.CmisNavigationService#getChildren(org. + * apache.opencmis.server .spi.CallContext, java.lang.String, + * java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, + * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, + * java.lang.Boolean, java.math.BigInteger, java.math.BigInteger, + * org.apache.opencmis.commons.api.ExtensionsData, + * org.apache.opencmis.server.spi.ObjectInfoHolder) + */ + 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) { + checkRepositoryId(repositoryId); + checkId("Folder Id", folderId); + includeAllowableActions = getDefaultFalse(includeAllowableActions); + includeRelationships = getDefault(includeRelationships); + renditionFilter = getDefaultRenditionFilter(renditionFilter); + includePathSegment = getDefaultFalse(includePathSegment); + maxItems = getMaxItems(maxItems); + skipCount = getSkipCount(skipCount); + + try { + return fService.getChildren(context, repositoryId, folderId, filter, orderBy, includeAllowableActions, + includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, extension, + objectInfos); + } catch (Exception e) { + throw createCmisException(e); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.server.spi.CmisNavigationService#getDescendants(org + * .apache.opencmis.server .spi.CallContext, java.lang.String, + * java.lang.String, java.math.BigInteger, java.lang.String, + * java.lang.Boolean, + * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, + * java.lang.Boolean, org.apache.opencmis.commons.api.ExtensionsData, + * org.apache.opencmis.server.spi.ObjectInfoHolder) + */ + public List getDescendants(CallContext context, String repositoryId, String folderId, + BigInteger depth, String filter, Boolean includeAllowableActions, + IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment, + ExtensionsData extension, ObjectInfoHolder objectInfos) { + checkRepositoryId(repositoryId); + checkId("Folder Id", folderId); + depth = getDepth(depth); + includeAllowableActions = getDefaultFalse(includeAllowableActions); + includeRelationships = getDefault(includeRelationships); + renditionFilter = getDefaultRenditionFilter(renditionFilter); + includePathSegment = getDefaultFalse(includePathSegment); + + try { + return fService.getDescendants(context, repositoryId, folderId, depth, filter, includeAllowableActions, + includeRelationships, renditionFilter, includePathSegment, extension, objectInfos); + } catch (Exception e) { + throw createCmisException(e); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.server.spi.CmisNavigationService#getFolderParent( + * org.apache.opencmis.server .spi.CallContext, java.lang.String, + * java.lang.String, java.lang.String, + * org.apache.opencmis.commons.api.ExtensionsData, + * org.apache.opencmis.server.spi.ObjectInfoHolder) + */ + public ObjectData getFolderParent(CallContext context, String repositoryId, String folderId, String filter, + ExtensionsData extension, ObjectInfoHolder objectInfos) { + checkRepositoryId(repositoryId); + checkId("Folder Id", folderId); + + try { + return fService.getFolderParent(context, repositoryId, folderId, filter, extension, objectInfos); + } catch (Exception e) { + throw createCmisException(e); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.server.spi.CmisNavigationService#getFolderTree(org + * .apache.opencmis.server .spi.CallContext, java.lang.String, + * java.lang.String, java.math.BigInteger, java.lang.String, + * java.lang.Boolean, + * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, + * java.lang.Boolean, org.apache.opencmis.commons.api.ExtensionsData, + * org.apache.opencmis.server.spi.ObjectInfoHolder) + */ + public List getFolderTree(CallContext context, String repositoryId, String folderId, + BigInteger depth, String filter, Boolean includeAllowableActions, + IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment, + ExtensionsData extension, ObjectInfoHolder objectInfos) { + checkRepositoryId(repositoryId); + checkId("Folder Id", folderId); + depth = getDepth(depth); + includeAllowableActions = getDefaultFalse(includeAllowableActions); + includeRelationships = getDefault(includeRelationships); + renditionFilter = getDefaultRenditionFilter(renditionFilter); + includePathSegment = getDefaultFalse(includePathSegment); + + try { + return fService.getFolderTree(context, repositoryId, folderId, depth, filter, includeAllowableActions, + includeRelationships, renditionFilter, includePathSegment, extension, objectInfos); + } catch (Exception e) { + throw createCmisException(e); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.apache.opencmis.server.spi.CmisNavigationService#getObjectParents + * (org.apache.opencmis.server .spi.CallContext, java.lang.String, + * java.lang.String, java.lang.String, java.lang.Boolean, + * org.apache.opencmis.commons.enums.IncludeRelationships, java.lang.String, + * java.lang.Boolean, org.apache.opencmis.commons.api.ExtensionsData, + * org.apache.opencmis.server.spi.ObjectInfoHolder) + */ + public List getObjectParents(CallContext context, String repositoryId, String objectId, + String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, + String renditionFilter, Boolean includeRelativePathSegment, ExtensionsData extension, + ObjectInfoHolder objectInfos) { + checkRepositoryId(repositoryId); + checkId("Object Id", objectId); + includeAllowableActions = getDefaultFalse(includeAllowableActions); + includeRelationships = getDefault(includeRelationships); + renditionFilter = getDefaultRenditionFilter(renditionFilter); + includeRelativePathSegment = getDefaultFalse(includeRelativePathSegment); + + try { + return fService.getObjectParents(context, repositoryId, objectId, filter, includeAllowableActions, + includeRelationships, renditionFilter, includeRelativePathSegment, extension, objectInfos); + } catch (Exception e) { + throw createCmisException(e); + } + } } Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java?rev=934896&r1=934895&r2=934896&view=diff ============================================================================== --- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java (original) +++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/ObjectInfoHelper.java Fri Apr 16 14:14:00 2010 @@ -18,7 +18,6 @@ */ package org.apache.chemistry.opencmis.server.support; - import java.math.BigInteger; import java.util.ArrayList; import java.util.GregorianCalendar; @@ -51,457 +50,433 @@ import org.apache.chemistry.opencmis.ser import org.apache.chemistry.opencmis.server.spi.RenditionInfo; import org.apache.chemistry.opencmis.server.spi.RenditionInfosImpl; - /** - * A helper class used from various methods to fill the ObjectInfoHolder structure with - * the required information to generate all the links in the AtomPub binding. Use this - * class as a convenience class for starting the implementation. For productive use it - * is highly recommended that a server implementation replaces this implementation by - * a more efficient one. This default implementation can only rely on the services and - * therefore requires a round-trip for each object to the server once again. This can - * be avoided in a repository specific implementation. - * + * A helper class used from various methods to fill the ObjectInfoHolder + * structure with the required information to generate all the links in the + * AtomPub binding. Use this class as a convenience class for starting the + * implementation. For productive use it is highly recommended that a server + * implementation replaces this implementation by a more efficient one. This + * default implementation can only rely on the services and therefore requires a + * round-trip for each object to the server once again. This can be avoided in a + * repository specific implementation. + * */ -public class ObjectInfoHelper -{ - private CmisObjectService _objSvc; - private CmisRepositoryService _repSvc; - private CmisNavigationService _navSvc; - - private Map _repos = new HashMap(); - private Map _mapPolicies = new HashMap(); - private Map _mapRelationships = new HashMap(); - - public ObjectInfoHelper(CmisRepositoryService repSvc, CmisObjectService objSvc, CmisNavigationService navSvc) { - _objSvc = objSvc; - _repSvc = repSvc; - _navSvc = navSvc; - } - - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objectId - * object to retrieve information for - * @param objectInfos - * Holder to fill with information - */ - public ObjectData fillObjectInfoHolder(CallContext context, String repositoryId, String objectId, - ObjectInfoHolder objectInfos) { - - if (null == objectInfos || null == objectId) - return null; - - // call getObject to get the required information to fill ObjectInfoHolder - ObjectData objData = getObject(context, repositoryId, objectId); - fillObjectInfoHolder(context, repositoryId, objData, objectInfos); - - return objData; // might be useful as return value in some service methods - } - - /** - * Fill object in - * @param context - * @param repositoryId - * @param objData - * @param filter - * @param objectInfos - */ - public void fillObjectInfoHolder(CallContext context, String repositoryId, ObjectData objData, - String filter, ObjectInfoHolder objectInfos) { - // fill objectInfos - if (filterContainsRequiredProperties(filter)) - fillObjectInfoHolder(context, repositoryId, objData, objectInfos); - else // get object again as we need almost all system properties - fillObjectInfoHolder(context, repositoryId, objData.getId(), objectInfos); - } - - public boolean filterContainsRequiredProperties(String filter) { - if (filter==null) - return false; - if (filter.equals("*")) - return true; - if (!filter.contains(PropertyIds.NAME)) - return false; - if (!filter.contains(PropertyIds.CREATED_BY)) - return false; - if (!filter.contains(PropertyIds.CREATION_DATE)) - return false; - if (!filter.contains(PropertyIds.LAST_MODIFICATION_DATE)) - return false; - if (!filter.contains(PropertyIds.OBJECT_TYPE_ID)) - return false; - if (!filter.contains(PropertyIds.BASE_TYPE_ID)) - return false; - if (!filter.contains(PropertyIds.CONTENT_STREAM_FILE_NAME)) - return false; - if (!filter.contains(PropertyIds.CONTENT_STREAM_MIME_TYPE)) - return false; - if (!filter.contains(PropertyIds.CONTENT_STREAM_ID)) - return false; - return true; - - } - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objData - * object data to grab information from - * @param objectInfos - * Holder to fill with information - */ - public void fillObjectInfoHolder(CallContext context, String repositoryId, ObjectData objData, - ObjectInfoHolder objectInfos) { - - if (null==objData || null==objectInfos) - return; - - // Get required information about the repository and cache it for later use: - - Map> properties = objData.getProperties().getProperties(); - RepositoryCapabilities repoCaps = _repos.get(repositoryId); - if (null == repoCaps) { - RepositoryInfo repoInfo = _repSvc.getRepositoryInfo(null, repositoryId, null); - repoCaps = repoInfo.getCapabilities(); - _repos.put(repositoryId, repoCaps); - } - - Boolean supportsRelationships = _mapRelationships.get(repositoryId); - Boolean supportsPolicies = _mapPolicies.get(repositoryId); - if (null == supportsRelationships || null == supportsPolicies) { - supportsPolicies = supportsRelationships = false; - TypeDefinitionList children = _repSvc.getTypeChildren(context, repositoryId, null, false, - BigInteger.valueOf(100), BigInteger.ZERO, null); - for (TypeDefinition typeDefinition : children.getList()) { - if (typeDefinition.getId().equals(BaseTypeId.CMIS_RELATIONSHIP)) - supportsRelationships = true; - if (typeDefinition.getId().equals(BaseTypeId.CMIS_POLICY)) - supportsPolicies = true; - } - _mapRelationships.put(repositoryId, supportsRelationships); - _mapPolicies.put(repositoryId, supportsPolicies); - } - - ObjectInfoImpl objInfo = new ObjectInfoImpl(); - // Fill all setters: - objInfo.setId(objData.getId()); - objInfo.setName(getStringProperty(properties, PropertyIds.NAME)); - objInfo.setCreatedBy(getStringProperty(properties, PropertyIds.CREATED_BY)); - objInfo.setCreationDate(getDateProperty(properties, PropertyIds.CREATION_DATE)); - objInfo.setLastModificationDate(getDateProperty(properties, PropertyIds.LAST_MODIFICATION_DATE)); - objInfo.setTypeId(getStringProperty(properties, PropertyIds.OBJECT_TYPE_ID)); - String baseId = getStringProperty(properties, PropertyIds.BASE_TYPE_ID); - objInfo.setBaseType(BaseTypeId.fromValue(baseId)); - - boolean isVersioned = getStringProperty(properties, PropertyIds.VERSION_SERIES_ID) != null; - // versioning information: - if (isVersioned) { - objInfo.setIsCurrentVersion(getBooleanProperty(properties, PropertyIds.IS_LATEST_VERSION)); - objInfo.setVersionSeriesId(getStringProperty(properties, PropertyIds.VERSION_SERIES_ID)); - objInfo.setWorkingCopyId(getStringProperty(properties, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID)); - objInfo.setWorkingCopyOriginalId(null); - } else { // unversioned document - objInfo.setIsCurrentVersion (true); - objInfo.setVersionSeriesId(null); - objInfo.setWorkingCopyId(null); - objInfo.setWorkingCopyOriginalId(null); - } - - String fileName = getStringProperty(properties, PropertyIds.CONTENT_STREAM_FILE_NAME); - String mimeType = getStringProperty(properties, PropertyIds.CONTENT_STREAM_MIME_TYPE); - String streamId = getStringProperty(properties, PropertyIds.CONTENT_STREAM_ID); - BigInteger length = getIntegerProperty(properties, PropertyIds.CONTENT_STREAM_LENGTH); - boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null; - if (hasContent) { - objInfo.setHasContent(hasContent); - objInfo.setContentType(mimeType); - objInfo.setFileName(fileName); - } else { - objInfo.setHasContent(false); - objInfo.setContentType(null); - objInfo.setFileName(null); - } - - if (objInfo.getBaseType() == BaseTypeId.CMIS_FOLDER) - objInfo.setHasParent(getStringProperty(properties, PropertyIds.PARENT_ID) != null); - else if (objInfo.getBaseType() == BaseTypeId.CMIS_DOCUMENT) { - if (repoCaps.isUnfilingSupported()) - objInfo.setHasParent(documentHasParent(context, repositoryId, objData.getId())); - else - objInfo.setHasParent(true); - } else - objInfo.setHasParent(false); - - // Renditions, currently not supported by in-memory provider - objInfo.setRenditionInfos(convertRenditions(objData.getRenditions())); - - List sourceIds = new ArrayList(); - List targetIds = new ArrayList(); - getRelationshipIds(objData, sourceIds, targetIds); - - // Relationships, currently not supported - objInfo.setSupportsRelationships(supportsRelationships); - objInfo.setRelationshipSourceIds(sourceIds); - objInfo.setRelationshipTargetIds(targetIds); - - objInfo.setSupportsPolicies(supportsPolicies); - - objInfo.setHasAcl(repoCaps.getAclCapability() != CapabilityAcl.NONE); - - String baseTypeId = getStringProperty(properties, PropertyIds.BASE_TYPE_ID); - boolean isFolder = baseTypeId != null && baseTypeId.equals(BaseTypeId.CMIS_FOLDER.value()); - - objInfo.setSupportsDescendants(isFolder && repoCaps.isGetDescendantsSupported());; - objInfo.setSupportsFolderTree(isFolder && repoCaps.isGetFolderTreeSupported()); - - objectInfos.addObjectInfo(objInfo); - } - - - - - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objList - * object list, fill information for each element - * @param objectInfos - * Holder to fill with information - */ - public void fillObjectInfoHolder( - CallContext context, - String repositoryId, - ObjectList objList, - ObjectInfoHolder objectInfos) - { - - if (null != objectInfos && null != objList && null != objList.getObjects()) { - // Fill object information for all children in result list - List listObjects = objList.getObjects(); - if (null != listObjects) - for (ObjectData object : listObjects) { - fillObjectInfoHolder(context, repositoryId, object.getId(), objectInfos); - } - } - } - - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objList - * object list, fill information for each element - * @param objectInfos - * Holder to fill with information - */ - public void fillObjectInfoHolder( - CallContext context, - String repositoryId, - List objList, - ObjectInfoHolder objectInfos) - { - if (null == objectInfos || null == objList) - return; - - // Fill object information for all children in result list - for (ObjectData object : objList) { - fillObjectInfoHolder(context, repositoryId, object.getId(), objectInfos); - } - } - - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objList - * object list, fill information for each element - * @param objectInfos - * Holder to fill with information - */ - public void fillObjectInfoHolder( - CallContext context, - String repositoryId, - ObjectInFolderList objList, - ObjectInfoHolder objectInfos) - { - if (null == objectInfos || null == objList || objList.getObjects() == null) - return; - - // Fill object information for all children in result list - for (ObjectInFolderData object : objList.getObjects()) { - fillObjectInfoHolder(context, repositoryId, object.getObject().getId(), objectInfos); - } - } - - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objList - * object list, fill information for each element - * @param objectInfos - * Holder to fill with information - */ - public void fillObjectInfoHolderObjectParentData( - CallContext context, - String repositoryId, - List objParents, - ObjectInfoHolder objectInfos) - { - if (null == objectInfos || null == objParents) - return; - - for (ObjectParentData object : objParents) { - fillObjectInfoHolder(context, repositoryId, object.getObject().getId(), objectInfos); - } - } - - /** - * fill an ObjectInfoHolder object with required information needed for Atom binding - * to be able to generate the necessary links in AtomPub - * - * @param context - * call context of the current request - * @param repositoryId - * id of repository - * @param objList - * object list, fill information for each element recursively - * @param objectInfos - * Holder to fill with information - */ - public void fillObjectInfoHolderFolderContainer( - CallContext context, - String repositoryId, - List oifcList, - ObjectInfoHolder objectInfos) - { - if (null == objectInfos || null == oifcList) - return; - - for (ObjectInFolderContainer object : oifcList) { - fillObjectInfoHolderFolderContainer(context, repositoryId, object, objectInfos); - } - } - - private void fillObjectInfoHolderFolderContainer( - CallContext context, - String repositoryId, - ObjectInFolderContainer oifc, - ObjectInfoHolder objectInfos) - { - if (null == objectInfos || null == oifc || oifc.getObject() == null - || oifc.getObject().getObject() == null) - return; - - fillObjectInfoHolder(context, repositoryId, oifc.getObject().getObject(), objectInfos); - - if (null!=oifc.getChildren()) - for (ObjectInFolderContainer object : oifc.getChildren()) { - // call recursively - fillObjectInfoHolderFolderContainer(context, repositoryId, object, objectInfos); - } - } - - private Boolean getBooleanProperty(Map> props, String key) { - PropertyData pdVal = props.get(key); - Boolean val = null==pdVal ? null : (Boolean) pdVal.getFirstValue(); - return val; - } - - private String getStringProperty(Map> props, String key) { - PropertyData pdVal = props.get(key); - String val = null==pdVal ? null : (String) pdVal.getFirstValue(); - return val; - } - - private GregorianCalendar getDateProperty(Map> props, String key) { - PropertyData pdVal = props.get(key); - GregorianCalendar val = null==pdVal ? null : (GregorianCalendar) pdVal.getFirstValue(); - return val; - } - - private BigInteger getIntegerProperty(Map> props, String key) { - PropertyData pdVal = props.get(key); - BigInteger val = null==pdVal ? null : (BigInteger) pdVal.getFirstValue(); - return val; - } - - private ObjectData getObject(CallContext context, String repositoryId, String objectId) { - - ObjectData od = _objSvc.getObject(context, repositoryId, objectId, null, false, - IncludeRelationships.BOTH, "*", true, true, null, null); - return od; - } - - private List convertRenditions(List renditions) { - - if (null==renditions) - return null; - - List rendInfos = new ArrayList(renditions.size()); - RenditionInfosImpl ri = new RenditionInfosImpl(); - for (RenditionData rd : renditions) { - ri.setContentType(rd.getMimeType()); - ri.setId(rd.getStreamId()); - ri.setKind(rd.getKind()); - ri.setLength(rd.getBigLength()); - ri.setTitle(rd.getTitle()); - rendInfos.add(ri); - } - return rendInfos; - } - - private void getRelationshipIds(ObjectData objData, List sourceIds, List targetIds) { - if (null==objData || null == objData.getRelationships()) - return; - - String objectId = objData.getId(); - for (ObjectData rel : objData.getRelationships()) { - String relId = getStringProperty(rel.getProperties().getProperties(), PropertyIds.OBJECT_ID); - String sourceId = getStringProperty(rel.getProperties().getProperties(), PropertyIds.SOURCE_ID); - String targetId = getStringProperty(rel.getProperties().getProperties(), PropertyIds.TARGET_ID); - if (objectId.equals(sourceId)) - sourceIds.add(relId); - if (objectId.equals(targetId)) - targetIds.add(relId); - } - } - - private boolean documentHasParent(CallContext context, String repositoryId, String objectId) - { - List opd = _navSvc.getObjectParents(context, repositoryId, objectId, null, false, IncludeRelationships.NONE, - null, false, null, null); +public class ObjectInfoHelper { + private CmisObjectService _objSvc; + private CmisRepositoryService _repSvc; + private CmisNavigationService _navSvc; + + private Map _repos = new HashMap(); + private Map _mapPolicies = new HashMap(); + private Map _mapRelationships = new HashMap(); + + public ObjectInfoHelper(CmisRepositoryService repSvc, CmisObjectService objSvc, CmisNavigationService navSvc) { + _objSvc = objSvc; + _repSvc = repSvc; + _navSvc = navSvc; + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objectId + * object to retrieve information for + * @param objectInfos + * Holder to fill with information + */ + public ObjectData fillObjectInfoHolder(CallContext context, String repositoryId, String objectId, + ObjectInfoHolder objectInfos) { + + if (null == objectInfos || null == objectId) + return null; + + // call getObject to get the required information to fill + // ObjectInfoHolder + ObjectData objData = getObject(context, repositoryId, objectId); + fillObjectInfoHolder(context, repositoryId, objData, objectInfos); + + return objData; // might be useful as return value in some service + // methods + } + + /** + * Fill object in + * + * @param context + * @param repositoryId + * @param objData + * @param filter + * @param objectInfos + */ + public void fillObjectInfoHolder(CallContext context, String repositoryId, ObjectData objData, String filter, + ObjectInfoHolder objectInfos) { + // fill objectInfos + if (filterContainsRequiredProperties(filter)) + fillObjectInfoHolder(context, repositoryId, objData, objectInfos); + else + // get object again as we need almost all system properties + fillObjectInfoHolder(context, repositoryId, objData.getId(), objectInfos); + } + + public boolean filterContainsRequiredProperties(String filter) { + if (filter == null) + return false; + if (filter.equals("*")) + return true; + if (!filter.contains(PropertyIds.NAME)) + return false; + if (!filter.contains(PropertyIds.CREATED_BY)) + return false; + if (!filter.contains(PropertyIds.CREATION_DATE)) + return false; + if (!filter.contains(PropertyIds.LAST_MODIFICATION_DATE)) + return false; + if (!filter.contains(PropertyIds.OBJECT_TYPE_ID)) + return false; + if (!filter.contains(PropertyIds.BASE_TYPE_ID)) + return false; + if (!filter.contains(PropertyIds.CONTENT_STREAM_FILE_NAME)) + return false; + if (!filter.contains(PropertyIds.CONTENT_STREAM_MIME_TYPE)) + return false; + if (!filter.contains(PropertyIds.CONTENT_STREAM_ID)) + return false; + return true; + + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objData + * object data to grab information from + * @param objectInfos + * Holder to fill with information + */ + public void fillObjectInfoHolder(CallContext context, String repositoryId, ObjectData objData, + ObjectInfoHolder objectInfos) { + + if (null == objData || null == objectInfos) + return; + + // Get required information about the repository and cache it for later + // use: + + Map> properties = objData.getProperties().getProperties(); + RepositoryCapabilities repoCaps = _repos.get(repositoryId); + if (null == repoCaps) { + RepositoryInfo repoInfo = _repSvc.getRepositoryInfo(null, repositoryId, null); + repoCaps = repoInfo.getCapabilities(); + _repos.put(repositoryId, repoCaps); + } + + Boolean supportsRelationships = _mapRelationships.get(repositoryId); + Boolean supportsPolicies = _mapPolicies.get(repositoryId); + if (null == supportsRelationships || null == supportsPolicies) { + supportsPolicies = supportsRelationships = false; + TypeDefinitionList children = _repSvc.getTypeChildren(context, repositoryId, null, false, BigInteger + .valueOf(100), BigInteger.ZERO, null); + for (TypeDefinition typeDefinition : children.getList()) { + if (typeDefinition.getId().equals(BaseTypeId.CMIS_RELATIONSHIP)) + supportsRelationships = true; + if (typeDefinition.getId().equals(BaseTypeId.CMIS_POLICY)) + supportsPolicies = true; + } + _mapRelationships.put(repositoryId, supportsRelationships); + _mapPolicies.put(repositoryId, supportsPolicies); + } + + ObjectInfoImpl objInfo = new ObjectInfoImpl(); + // Fill all setters: + objInfo.setId(objData.getId()); + objInfo.setName(getStringProperty(properties, PropertyIds.NAME)); + objInfo.setCreatedBy(getStringProperty(properties, PropertyIds.CREATED_BY)); + objInfo.setCreationDate(getDateProperty(properties, PropertyIds.CREATION_DATE)); + objInfo.setLastModificationDate(getDateProperty(properties, PropertyIds.LAST_MODIFICATION_DATE)); + objInfo.setTypeId(getStringProperty(properties, PropertyIds.OBJECT_TYPE_ID)); + String baseId = getStringProperty(properties, PropertyIds.BASE_TYPE_ID); + objInfo.setBaseType(BaseTypeId.fromValue(baseId)); + + boolean isVersioned = getStringProperty(properties, PropertyIds.VERSION_SERIES_ID) != null; + // versioning information: + if (isVersioned) { + objInfo.setIsCurrentVersion(getBooleanProperty(properties, PropertyIds.IS_LATEST_VERSION)); + objInfo.setVersionSeriesId(getStringProperty(properties, PropertyIds.VERSION_SERIES_ID)); + objInfo.setWorkingCopyId(getStringProperty(properties, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID)); + objInfo.setWorkingCopyOriginalId(null); + } else { // unversioned document + objInfo.setIsCurrentVersion(true); + objInfo.setVersionSeriesId(null); + objInfo.setWorkingCopyId(null); + objInfo.setWorkingCopyOriginalId(null); + } + + String fileName = getStringProperty(properties, PropertyIds.CONTENT_STREAM_FILE_NAME); + String mimeType = getStringProperty(properties, PropertyIds.CONTENT_STREAM_MIME_TYPE); + String streamId = getStringProperty(properties, PropertyIds.CONTENT_STREAM_ID); + BigInteger length = getIntegerProperty(properties, PropertyIds.CONTENT_STREAM_LENGTH); + boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null; + if (hasContent) { + objInfo.setHasContent(hasContent); + objInfo.setContentType(mimeType); + objInfo.setFileName(fileName); + } else { + objInfo.setHasContent(false); + objInfo.setContentType(null); + objInfo.setFileName(null); + } + + if (objInfo.getBaseType() == BaseTypeId.CMIS_FOLDER) + objInfo.setHasParent(getStringProperty(properties, PropertyIds.PARENT_ID) != null); + else if (objInfo.getBaseType() == BaseTypeId.CMIS_DOCUMENT) { + if (repoCaps.isUnfilingSupported()) + objInfo.setHasParent(documentHasParent(context, repositoryId, objData.getId())); + else + objInfo.setHasParent(true); + } else + objInfo.setHasParent(false); + + // Renditions, currently not supported by in-memory provider + objInfo.setRenditionInfos(convertRenditions(objData.getRenditions())); + + List sourceIds = new ArrayList(); + List targetIds = new ArrayList(); + getRelationshipIds(objData, sourceIds, targetIds); + + // Relationships, currently not supported + objInfo.setSupportsRelationships(supportsRelationships); + objInfo.setRelationshipSourceIds(sourceIds); + objInfo.setRelationshipTargetIds(targetIds); + + objInfo.setSupportsPolicies(supportsPolicies); + + objInfo.setHasAcl(repoCaps.getAclCapability() != CapabilityAcl.NONE); + + String baseTypeId = getStringProperty(properties, PropertyIds.BASE_TYPE_ID); + boolean isFolder = baseTypeId != null && baseTypeId.equals(BaseTypeId.CMIS_FOLDER.value()); + + objInfo.setSupportsDescendants(isFolder && repoCaps.isGetDescendantsSupported()); + ; + objInfo.setSupportsFolderTree(isFolder && repoCaps.isGetFolderTreeSupported()); + + objectInfos.addObjectInfo(objInfo); + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objList + * object list, fill information for each element + * @param objectInfos + * Holder to fill with information + */ + public void fillObjectInfoHolder(CallContext context, String repositoryId, ObjectList objList, + ObjectInfoHolder objectInfos) { + + if (null != objectInfos && null != objList && null != objList.getObjects()) { + // Fill object information for all children in result list + List listObjects = objList.getObjects(); + if (null != listObjects) + for (ObjectData object : listObjects) { + fillObjectInfoHolder(context, repositoryId, object.getId(), objectInfos); + } + } + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objList + * object list, fill information for each element + * @param objectInfos + * Holder to fill with information + */ + public void fillObjectInfoHolder(CallContext context, String repositoryId, List objList, + ObjectInfoHolder objectInfos) { + if (null == objectInfos || null == objList) + return; + + // Fill object information for all children in result list + for (ObjectData object : objList) { + fillObjectInfoHolder(context, repositoryId, object.getId(), objectInfos); + } + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objList + * object list, fill information for each element + * @param objectInfos + * Holder to fill with information + */ + public void fillObjectInfoHolder(CallContext context, String repositoryId, ObjectInFolderList objList, + ObjectInfoHolder objectInfos) { + if (null == objectInfos || null == objList || objList.getObjects() == null) + return; + + // Fill object information for all children in result list + for (ObjectInFolderData object : objList.getObjects()) { + fillObjectInfoHolder(context, repositoryId, object.getObject().getId(), objectInfos); + } + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objList + * object list, fill information for each element + * @param objectInfos + * Holder to fill with information + */ + public void fillObjectInfoHolderObjectParentData(CallContext context, String repositoryId, + List objParents, ObjectInfoHolder objectInfos) { + if (null == objectInfos || null == objParents) + return; + + for (ObjectParentData object : objParents) { + fillObjectInfoHolder(context, repositoryId, object.getObject().getId(), objectInfos); + } + } + + /** + * fill an ObjectInfoHolder object with required information needed for Atom + * binding to be able to generate the necessary links in AtomPub + * + * @param context + * call context of the current request + * @param repositoryId + * id of repository + * @param objList + * object list, fill information for each element recursively + * @param objectInfos + * Holder to fill with information + */ + public void fillObjectInfoHolderFolderContainer(CallContext context, String repositoryId, + List oifcList, ObjectInfoHolder objectInfos) { + if (null == objectInfos || null == oifcList) + return; + + for (ObjectInFolderContainer object : oifcList) { + fillObjectInfoHolderFolderContainer(context, repositoryId, object, objectInfos); + } + } + + private void fillObjectInfoHolderFolderContainer(CallContext context, String repositoryId, + ObjectInFolderContainer oifc, ObjectInfoHolder objectInfos) { + if (null == objectInfos || null == oifc || oifc.getObject() == null || oifc.getObject().getObject() == null) + return; + + fillObjectInfoHolder(context, repositoryId, oifc.getObject().getObject(), objectInfos); + + if (null != oifc.getChildren()) + for (ObjectInFolderContainer object : oifc.getChildren()) { + // call recursively + fillObjectInfoHolderFolderContainer(context, repositoryId, object, objectInfos); + } + } + + private Boolean getBooleanProperty(Map> props, String key) { + PropertyData pdVal = props.get(key); + Boolean val = null == pdVal ? null : (Boolean) pdVal.getFirstValue(); + return val; + } + + private String getStringProperty(Map> props, String key) { + PropertyData pdVal = props.get(key); + String val = null == pdVal ? null : (String) pdVal.getFirstValue(); + return val; + } + + private GregorianCalendar getDateProperty(Map> props, String key) { + PropertyData pdVal = props.get(key); + GregorianCalendar val = null == pdVal ? null : (GregorianCalendar) pdVal.getFirstValue(); + return val; + } + + private BigInteger getIntegerProperty(Map> props, String key) { + PropertyData pdVal = props.get(key); + BigInteger val = null == pdVal ? null : (BigInteger) pdVal.getFirstValue(); + return val; + } + + private ObjectData getObject(CallContext context, String repositoryId, String objectId) { + + ObjectData od = _objSvc.getObject(context, repositoryId, objectId, null, false, IncludeRelationships.BOTH, "*", + true, true, null, null); + return od; + } + + private List convertRenditions(List renditions) { + + if (null == renditions) + return null; + + List rendInfos = new ArrayList(renditions.size()); + RenditionInfosImpl ri = new RenditionInfosImpl(); + for (RenditionData rd : renditions) { + ri.setContentType(rd.getMimeType()); + ri.setId(rd.getStreamId()); + ri.setKind(rd.getKind()); + ri.setLength(rd.getBigLength()); + ri.setTitle(rd.getTitle()); + rendInfos.add(ri); + } + return rendInfos; + } + + private void getRelationshipIds(ObjectData objData, List sourceIds, List targetIds) { + if (null == objData || null == objData.getRelationships()) + return; + + String objectId = objData.getId(); + for (ObjectData rel : objData.getRelationships()) { + String relId = getStringProperty(rel.getProperties().getProperties(), PropertyIds.OBJECT_ID); + String sourceId = getStringProperty(rel.getProperties().getProperties(), PropertyIds.SOURCE_ID); + String targetId = getStringProperty(rel.getProperties().getProperties(), PropertyIds.TARGET_ID); + if (objectId.equals(sourceId)) + sourceIds.add(relId); + if (objectId.equals(targetId)) + targetIds.add(relId); + } + } + + private boolean documentHasParent(CallContext context, String repositoryId, String objectId) { + List opd = _navSvc.getObjectParents(context, repositoryId, objectId, null, false, + IncludeRelationships.NONE, null, false, null, null); - return opd!= null && opd.size()>0; - } + return opd != null && opd.size() > 0; + } } -