mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75551: Reverse Merge HEAD-BUG-FIX (5.0/Cloud) 74584: Reverse merged HEAD-BUG-FIX (5.0/Cloud) << Requires more work on the EOL branch >> 74416: Merged EOL to HEAD-BUG-FIX (5.0/Cloud) 74309: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0 - Start replacing references to the original CMIS code with Alfresco and chemistry Open CMIS classes 74342: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0 - Switch ServiceRegistry over to using Open CMIS classes 74406: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0 << Compiles and starts Share without error >> - Removed Original CMIS classes from the repository, remote-api and thor - Moved the CMIS.DictionaryBootstrap bean into opencmis-context.xml before removing cmis-api-context.xml - Some code was left under: root\projects\remote-api\source\java\org\alfresco\repo\cmis ...........................................................\client ...........................................................\ws ...........................................................\rest ................................test-java\org\alfresco\repo\cmis ................................................................\ws ................................................................\rest Will have to see if it should be be removed too, or if it is common with OpenCMIS 74407: ACE-2010 EOL Legally CMIS Inputs (2) in 5.0 - Removed left over code under: root\projects\remote-api\source\java\org\alfresco\repo\cmis ................................test-java\org\alfresco\repo\cmis - Removed an authentication URL test in QuickShareRestApiTest which was failing in the same way as the tests above. - Removed CXFAuthenticationSystemTest which appears to be using the original CMIS 74465: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 74464: ACE-2010 EOL Legacey CMIS Inputs (2) in 5.0 - New failure in QuickShareRestApiTest - CXFAuthenticationSystemTest (deleted) was still referenced in MiscSystemTestSuite git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77489 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
<import resource="classpath:alfresco/favourites-service-context.xml"/>
|
||||
<import resource="classpath:alfresco/swf-transform-context.xml"/>
|
||||
<import resource="classpath:alfresco/form-services-context.xml"/>
|
||||
<import resource="classpath:alfresco/cmis-api-context.xml" />
|
||||
<import resource="classpath:alfresco/opencmis-context.xml" />
|
||||
<import resource="classpath:alfresco/period-type-context.xml" />
|
||||
<import resource="classpath*:alfresco/node-locator-context.xml" />
|
||||
|
@@ -1,133 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="CMISMapping" class="org.alfresco.cmis.mapping.CMISMapping" >
|
||||
<property name="serviceRegistry">
|
||||
<ref bean="ServiceRegistry" />
|
||||
</property>
|
||||
<property name="CMISService">
|
||||
<ref bean="CMISService" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="CMISService" class="org.alfresco.cmis.mapping.CMISServicesImpl">
|
||||
<property name="CMISSpecVersion"><value>1.0</value></property>
|
||||
<property name="CMISSpecTitle"><value>Version 1.0 OASIS Standard</value></property>
|
||||
<property name="defaultStore"><value>${spaces.store}</value></property>
|
||||
<property name="defaultRootPath"><value>/${spaces.company_home.childname}</value></property>
|
||||
<property name="dictionaryService" ref="dictionaryService" />
|
||||
<property name="namespaceService" ref="namespaceService" />
|
||||
<property name="CMISDictionaryService" ref="CMISDictionaryService" />
|
||||
<property name="CMISRenditionService" ref="CMISRenditionService" />
|
||||
<property name="searchService" ref="SearchService" />
|
||||
<property name="transactionHelper" ref="retryingTransactionHelper" />
|
||||
<property name="tenantAdminService" ref="tenantAdminService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="contentService" ref="ContentService" />
|
||||
<property name="repository" ref="repositoryHelper" />
|
||||
<property name="checkOutCheckInService" ref="CheckoutCheckinService" />
|
||||
<property name="versionService" ref="VersionService" />
|
||||
</bean>
|
||||
|
||||
<bean id="CMISDictionaryService" class="org.alfresco.cmis.dictionary.CMISStrictDictionaryService" >
|
||||
<property name="dictionaryService">
|
||||
<ref bean="dictionaryService" />
|
||||
</property>
|
||||
<property name="dictionaryDAO">
|
||||
<ref bean="dictionaryDAO" />
|
||||
</property>
|
||||
<property name="CMISMapping">
|
||||
<ref bean="CMISMapping" />
|
||||
</property>
|
||||
<property name="singletonCache" ref="immutableSingletonCache"/>
|
||||
</bean>
|
||||
|
||||
<bean id="CMIS.DictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
|
||||
<property name="models">
|
||||
<list>
|
||||
<value>alfresco/model/cmisModel.xml</value>
|
||||
<value>alfresco/model/cmisTestModel.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="CMISQueryService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
||||
<property name="sourceApplicationContextFactory">
|
||||
<ref bean="Search" />
|
||||
</property>
|
||||
<property name="sourceBeanName">
|
||||
<value>search.CMISQueryService</value>
|
||||
</property>
|
||||
<property name="interfaces">
|
||||
<list>
|
||||
<value>org.alfresco.cmis.CMISQueryService</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="CMISRenditionService" class="org.alfresco.cmis.renditions.CMISRenditionServiceImpl">
|
||||
<property name="renditionKindMapping">
|
||||
<map>
|
||||
<entry key="cmis:thumbnail">
|
||||
<list><value>doclib</value></list>
|
||||
</entry>
|
||||
<entry key="alf:webpreview">
|
||||
<list><value>webpreview</value><value>imgpreview</value></list>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="customRenditions">
|
||||
<list>
|
||||
<bean class="org.alfresco.cmis.renditions.CMISRenditionImpl">
|
||||
<property name="streamId"><value>alf:icon16</value></property>
|
||||
<property name="mimeType"><value>image/gif</value></property>
|
||||
<property name="kind"><value>alf:icon16</value></property>
|
||||
<property name="width"><value>16</value></property>
|
||||
<property name="height"><value>16</value></property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.cmis.renditions.CMISRenditionImpl">
|
||||
<property name="streamId"><value>alf:icon32</value></property>
|
||||
<property name="mimeType"><value>image/gif</value></property>
|
||||
<property name="kind"><value>alf:icon32</value></property>
|
||||
<property name="width"><value>32</value></property>
|
||||
<property name="height"><value>32</value></property>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
<property name="thumbnailService">
|
||||
<ref bean="ThumbnailService" />
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="NodeService" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="CMISChangeLogService" class="org.alfresco.cmis.changelog.CMISChangeLogServiceImpl">
|
||||
<property name="cmisAuditApplicationName" value="CMISChangeLog" />
|
||||
<property name="changesOnTypeCapability">
|
||||
<list>
|
||||
<value>FOLDER</value>
|
||||
<value>DOCUMENT</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="auditService" ref="auditService" />
|
||||
</bean>
|
||||
|
||||
<bean id="CMISAccessControlService" class="org.alfresco.cmis.acl.CMISAccessControlServiceImpl" >
|
||||
<!-- Valid values are: NONE, DISCOVER, MANAGE -->
|
||||
<property name="aclCapabilityEnum" value="MANAGE" />
|
||||
<!-- Valid values are: BASIC, REPOSITORY, BOTH -->
|
||||
<property name="aclSupportedPermissionEnum" value="BOTH" />
|
||||
<!-- Alfrecso only supports PROPAGATE -->
|
||||
<property name="aclPropagationEnum" value="PROPAGATE" />
|
||||
<property name="permissionModelDao" ref="permissionsModelDAO" />
|
||||
<property name="permissionService" ref="PermissionService" />
|
||||
<property name="CMISMapping" ref="CMISMapping" />
|
||||
<property name="CMISDictionaryService" ref="CMISDictionaryService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -13,7 +13,6 @@
|
||||
<import resource="classpath:alfresco/application-context-core.xml" />
|
||||
|
||||
<!-- required to bring up the search subsystem -->
|
||||
<import resource="classpath:alfresco/cmis-api-context.xml" />
|
||||
<import resource="classpath:alfresco/opencmis-context.xml" />
|
||||
<import resource="classpath:alfresco/thumbnail-service-context.xml"/>
|
||||
<import resource="classpath:alfresco/rendition-services-context.xml"/>
|
||||
|
@@ -4,6 +4,15 @@
|
||||
<beans>
|
||||
<import resource="classpath:alfresco/opencmis-qnamefilter-context.xml" />
|
||||
|
||||
<bean id="CMIS.DictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
|
||||
<property name="models">
|
||||
<list>
|
||||
<value>alfresco/model/cmisModel.xml</value>
|
||||
<value>alfresco/model/cmisTestModel.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="OpenCMISPropertyAccessorMapping" class="org.alfresco.opencmis.mapping.RuntimePropertyAccessorMapping" init-method="init">
|
||||
<property name="serviceRegistry" ref="ServiceRegistry" />
|
||||
<property name="cmisConnector" ref="CMISConnector" />
|
||||
|
@@ -1,51 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="search.CMISQueryService" class="org.alfresco.cmis.search.CMISQueryServiceImpl" >
|
||||
<property name="CMISDictionaryService">
|
||||
<ref bean="CMISDictionaryService" />
|
||||
</property>
|
||||
<property name="CMISService">
|
||||
<ref bean="CMISService" />
|
||||
</property>
|
||||
<property name="queryEngine">
|
||||
<ref bean="search.adm.luceneQueryEngine" />
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="nodeService" />
|
||||
</property>
|
||||
<property name="alfrescoDictionaryService">
|
||||
<ref bean="dictionaryService" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="search.adm.luceneQueryEngine" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.repo.search.impl.querymodel.QueryEngine</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="search.adm.luceneQueryEngineImpl"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref bean="search.adm.luceneQueryEngineSecurity"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="search.adm.luceneQueryEngineSecurity" class="net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
|
||||
<property name="authenticationManager"><ref bean="authenticationManager"/></property>
|
||||
<property name="accessDecisionManager"><ref bean="accessDecisionManager"/></property>
|
||||
<property name="afterInvocationManager"><ref bean="afterInvocationManager"/></property>
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
org.alfresco.repo.search.impl.querymodel.QueryEngine.executeQuery=ACL_ALLOW,AFTER_ACL_NODE.sys:base.Read
|
||||
org.alfresco.repo.search.impl.querymodel.QueryEngine.getQueryModelFactory=ACL_ALLOW
|
||||
</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="search.CMISQueryService" class="org.alfresco.repo.search.impl.noindex.NoIndexCMISQueryServiceImpl" >
|
||||
<property name="cmisDictionaryService">
|
||||
<ref bean="CMISDictionaryService" />
|
||||
</property>
|
||||
<property name="cmisService">
|
||||
<ref bean="CMISService" />
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="nodeService" />
|
||||
</property>
|
||||
<property name="alfrescoDictionaryService">
|
||||
<ref bean="dictionaryService" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -1,24 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="search.CMISQueryService" class="org.alfresco.repo.search.impl.solr.SolrCMISQueryServiceImpl" >
|
||||
<property name="cmisDictionaryService">
|
||||
<ref bean="CMISDictionaryService" />
|
||||
</property>
|
||||
<property name="cmisService">
|
||||
<ref bean="CMISService" />
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="nodeService" />
|
||||
</property>
|
||||
<property name="alfrescoDictionaryService">
|
||||
<ref bean="dictionaryService" />
|
||||
</property>
|
||||
<property name="solrQueryLanguage">
|
||||
<ref bean="search.cmis.alfresco.switching" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISAccessControlEntriesGroupedByPrincipalId
|
||||
{
|
||||
/**
|
||||
* Get the principal id.
|
||||
* @return principal id
|
||||
*/
|
||||
public String getPrincipalId();
|
||||
|
||||
/**
|
||||
* Get the direct permissions
|
||||
* @return the direct permissions
|
||||
*/
|
||||
public List<String> getDirectPermissions();
|
||||
|
||||
/**
|
||||
* Get the indirect permissions
|
||||
* @return the indirect permissions
|
||||
*/
|
||||
public List<String> getIndirectPermissions();
|
||||
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
/**
|
||||
* An Access control entry
|
||||
*
|
||||
* Note: we report one permission at a time rather than group them
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISAccessControlEntry
|
||||
{
|
||||
/**
|
||||
* Get the principal id.
|
||||
* @return principal id
|
||||
*/
|
||||
public String getPrincipalId();
|
||||
|
||||
/**
|
||||
* Get the unique permission id
|
||||
* @return the unique permission id
|
||||
*/
|
||||
public String getPermission();
|
||||
|
||||
/**
|
||||
* Is the assignment direct on the object
|
||||
* @return <code>true</code> if directly assigned, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean getDirect();
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* An Access control report.
|
||||
* This is an ACL.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISAccessControlReport
|
||||
{
|
||||
/**
|
||||
* Get the list of ACEs.
|
||||
* @return the list of ACEs.
|
||||
*/
|
||||
public List<? extends CMISAccessControlEntry> getAccessControlEntries();
|
||||
|
||||
/**
|
||||
* Is this report exact?
|
||||
* If <code>false</code> then there are other other security constraints that apply.
|
||||
* This will always be false as we have global permission and deny entries that are not reported.
|
||||
* We do not explicitly check these cases - and return false - as we have global permission defined by default.
|
||||
*
|
||||
* @return <code>true</code> means the report fully describes security access, <code>false</code> means other
|
||||
* security constraints <i>may</i> apply but are not reported.
|
||||
*/
|
||||
public boolean isExact();
|
||||
|
||||
/**
|
||||
* Get ACEs grouped by principal id
|
||||
* @return ACEs grouped by principal id
|
||||
* @throws CMISConstraintException
|
||||
*/
|
||||
public List<? extends CMISAccessControlEntriesGroupedByPrincipalId> getAccessControlEntriesGroupedByPrincipalId() throws CMISConstraintException;
|
||||
|
||||
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.opencmis.CMISAccessControlFormatEnum;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Service for CMIS access control support.
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface CMISAccessControlService
|
||||
{
|
||||
/**
|
||||
* CMIS Read (properties and content)
|
||||
*/
|
||||
public static final String CMIS_READ_PERMISSION = "cmis:read";
|
||||
|
||||
/**
|
||||
* CMIS Write (properties and content)
|
||||
*/
|
||||
public static final String CMIS_WRITE_PERMISSION = "cmis:write";
|
||||
|
||||
/**
|
||||
* CMIS ALL permissions (includes all permissions defined within the repository)
|
||||
*/
|
||||
public static final String CMIS_ALL_PERMISSION = "cmis:all";
|
||||
|
||||
/**
|
||||
* Get the ACL capability enum.
|
||||
* @return the ACL capability enum.
|
||||
*/
|
||||
public CMISAclCapabilityEnum getAclCapability();
|
||||
|
||||
/**
|
||||
* Gets the supported permission types
|
||||
* @return the supported permission types
|
||||
*/
|
||||
public CMISAclSupportedPermissionEnum getSupportedPermissions();
|
||||
|
||||
/**
|
||||
* Get the ACL propagation enum.
|
||||
* @return the ACL propagation enum.
|
||||
*/
|
||||
public CMISAclPropagationEnum getAclPropagation();
|
||||
|
||||
/**
|
||||
* Get all the permissions defined by the repository.
|
||||
* @return a list of permissions
|
||||
*/
|
||||
public List<CMISPermissionDefinition> getRepositoryPermissions();
|
||||
|
||||
/**
|
||||
* Get the list of permission mappings.
|
||||
* @return get the permission mapping as defined by the CMIS specification.
|
||||
*/
|
||||
public List<? extends CMISPermissionMapping> getPermissionMappings();
|
||||
|
||||
/**
|
||||
* Gets the name of the principal who is used for anonymous access. This principal can then be passed to the ACL
|
||||
* services to specify what permissions anonymous users should have.
|
||||
*
|
||||
* @return name of the principal who is used for anonymous access
|
||||
*/
|
||||
public String getPrincipalAnonymous();
|
||||
|
||||
/**
|
||||
* Gets the name of the principal who is used to indicate any authenticated user. This principal can then be passed
|
||||
* to the ACL services to specify what permissions any authenticated user should have.
|
||||
*
|
||||
* @return name of the principal who is used to indicate any authenticated user
|
||||
*/
|
||||
public String getPrincipalAnyone();
|
||||
|
||||
/**
|
||||
* Get the ACLs set on a node.
|
||||
* @param nodeRef
|
||||
* @param format
|
||||
* @return an access control report
|
||||
*/
|
||||
public CMISAccessControlReport getAcl(NodeRef nodeRef, CMISAccessControlFormatEnum format);
|
||||
|
||||
/**
|
||||
* Update the ACEs on a node.
|
||||
* Those already existing, are preserved, those new are added and those missing are removed.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param acesToApply
|
||||
* @return an access control report of the final state
|
||||
* @throws CMISConstraintException
|
||||
*/
|
||||
public CMISAccessControlReport applyAcl(NodeRef nodeRef, List<CMISAccessControlEntry> acesToApply) throws CMISConstraintException;
|
||||
|
||||
/**
|
||||
* Update the ACEs on a node.
|
||||
* The deletions are applied before the additions.
|
||||
* Existing ACEs not deleted or added remain unchanged.
|
||||
*
|
||||
* @param nodeRef
|
||||
* @param acesToRemove
|
||||
* @param acesToAdd
|
||||
* @param propagation
|
||||
* @param format
|
||||
* @return an access control report of the final state
|
||||
* @throws CMISConstraintException
|
||||
*/
|
||||
public CMISAccessControlReport applyAcl(NodeRef nodeRef, List<CMISAccessControlEntry> acesToRemove, List<CMISAccessControlEntry> acesToAdd, CMISAclPropagationEnum propagation, CMISAccessControlFormatEnum format) throws CMISConstraintException;
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS ACL capability
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public enum CMISAclCapabilityEnum implements EnumLabel
|
||||
{
|
||||
/**
|
||||
* ACLs are not supported
|
||||
*/
|
||||
NONE("none"),
|
||||
/**
|
||||
* ACLs can be read but not set
|
||||
*/
|
||||
DISCOVER("discover"),
|
||||
/**
|
||||
* ACLs can be read and set
|
||||
*/
|
||||
MANAGE("manage");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISAclCapabilityEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory for CMISAclCapabilityEnum
|
||||
*/
|
||||
public static EnumFactory<CMISAclCapabilityEnum> FACTORY = new EnumFactory<CMISAclCapabilityEnum>(CMISAclCapabilityEnum.class, MANAGE, true);
|
||||
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS ACL propagation
|
||||
*
|
||||
* Used to request a particular behaviour or report back behaviour.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public enum CMISAclPropagationEnum implements EnumLabel
|
||||
{
|
||||
/**
|
||||
* The ACL only applies to the object
|
||||
* (not yet supported in Alfresco)
|
||||
*/
|
||||
OBJECT_ONLY("objectonly"),
|
||||
/**
|
||||
* ACLs are applied to all inheriting objects
|
||||
* (the default in Alfresco)
|
||||
*/
|
||||
PROPAGATE("propagate"),
|
||||
/**
|
||||
* Some other mechanism by which ACL changes influence other ACL's non-direct ACEs.
|
||||
*/
|
||||
REPOSITORY_DETERMINED("repositorydetermined");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISAclPropagationEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory for CMISAclPropagationEnum
|
||||
*/
|
||||
public static EnumFactory<CMISAclPropagationEnum> FACTORY = new EnumFactory<CMISAclPropagationEnum>(CMISAclPropagationEnum.class, PROPAGATE, true);
|
||||
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
|
||||
/**
|
||||
* Specifies which types of permissions are supported..
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public enum CMISAclSupportedPermissionEnum
|
||||
{
|
||||
/**
|
||||
* CMIS Basic permissions are supported.
|
||||
*/
|
||||
BASIC("basic"),
|
||||
/**
|
||||
* Repository specific permissions are supported.
|
||||
*/
|
||||
REPOSITORY("repository"),
|
||||
/**
|
||||
* both CMIS basic permissions and repository specific permissions are supported. (the default in Alfresco)
|
||||
*/
|
||||
BOTH("both");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISAclSupportedPermissionEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory for CMISAclSupportedPermissionEnum
|
||||
*/
|
||||
public static EnumFactory<CMISAclSupportedPermissionEnum> FACTORY = new EnumFactory<CMISAclSupportedPermissionEnum>(
|
||||
CMISAclSupportedPermissionEnum.class, BOTH, true);
|
||||
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
|
||||
public interface CMISActionEvaluator <T>
|
||||
{
|
||||
/**
|
||||
* Gets the CMIS Allowed Action
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISAllowedActionEnum getAction();
|
||||
|
||||
/**
|
||||
* Determines if an action is allowed on an object
|
||||
*
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
public boolean isAllowed(T object);
|
||||
}
|
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Allowed Action Enum
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public enum CMISAllowedActionEnum implements EnumLabel
|
||||
{
|
||||
|
||||
// navigation services
|
||||
CAN_GET_DESCENDANTS("canGetDescendants", "canGetDescendents.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetDescendents.Folder", "{http://www.alfresco.org/model/system/1.0}base.ReadChildren"),
|
||||
CAN_GET_FOLDER_TREE("canGetFolderTree"/*, "canGetFolderTree.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetFolderTree.Folder", "{http://www.alfresco.org/model/system/1.0}base.ReadChildren"*/),
|
||||
CAN_GET_CHILDREN("canGetChildren", "canGetChildren.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetChildren.Folder", "{http://www.alfresco.org/model/system/1.0}base.ReadChildren"),
|
||||
CAN_GET_FOLDER_PARENT("canGetFolderParent", "canGetParents.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetParents.Folder", "{http://www.alfresco.org/model/system/1.0}base.ReadProperties"),
|
||||
CAN_GET_OBJECT_PARENTS("canGetObjectParents", "canGetFolderParent.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetFolderParent.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadProperties"),
|
||||
|
||||
// object services
|
||||
CAN_CREATE_DOCUMENT("canCreateDocument", "canCreateDocument.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "canCreateDocument.Folder", "{http://www.alfresco.org/model/system/1.0}base.CreateChildren"),
|
||||
CAN_CREATE_FOLDER("canCreateFolder", "canCreateFolder.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "canCreateFolder.Folder", "{http://www.alfresco.org/model/system/1.0}base.CreateChildren"),
|
||||
CAN_CREATE_RELATIONSHIP("canCreateRelationship"),
|
||||
CAN_GET_PROPERTIES("canGetProperties", "canGetProperties.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetProperties.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadProperties"),
|
||||
CAN_GET_RENDITIONS("canGetRenditions"/*, "canGetRenditions.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetRenditions.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadProperties"*/),
|
||||
CAN_GET_CONTENT_STREAM("canGetContentStream", "canViewContent.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "canViewContent.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadContent"),
|
||||
CAN_UPDATE_PROPERTIES("canUpdateProperties", "canUpdateProperties.Object", CMISAccessControlService.CMIS_WRITE_PERMISSION, "canUpdateProperties.Object", "{http://www.alfresco.org/model/system/1.0}base.WriteProperties"),
|
||||
CAN_MOVE_OBJECT("canMoveObject", "canMove.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "canMove.Target", CMISAccessControlService.CMIS_ALL_PERMISSION, "canMove.Object", "{http://www.alfresco.org/model/system/1.0}base.DeleteNode", "canMove.Target", "{http://www.alfresco.org/model/system/1.0}base.CreateChildren"),
|
||||
CAN_DELETE_OBJECT("canDeleteObject", "canDelete.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "canDelete.Object", "{http://www.alfresco.org/model/system/1.0}base.DeleteNode"),
|
||||
CAN_SET_CONTENT_STREAM("canSetContentStream", "canSetContent.Document", CMISAccessControlService.CMIS_WRITE_PERMISSION, "canSetContent.Document", "{http://www.alfresco.org/model/system/1.0}base.WriteContent"),
|
||||
CAN_DELETE_CONTENT_STREAM("canDeleteContentStream", "canDeleteContent.Document", CMISAccessControlService.CMIS_WRITE_PERMISSION, "canDeleteContent.Document", "{http://www.alfresco.org/model/system/1.0}base.WriteContent"),
|
||||
CAN_DELETE_TREE("canDeleteTree", "canDeleteTree.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "canDeleteTree.Folder", "{http://www.alfresco.org/model/system/1.0}base.DeleteNode"),
|
||||
|
||||
// multi-filing services
|
||||
CAN_ADD_OBJECT_TO_FOLDER("canAddObjectToFolder", "canAddToFolder.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "canAddToFolder.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "canAddToFolder.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadProperties", "canAddToFolder.Folder", "{http://www.alfresco.org/model/system/1.0}base.CreateChildren"),
|
||||
CAN_REMOVE_OBJECT_FROM_FOLDER("canRemoveObjectFromFolder", "canRemoveFromFolder.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "canRemoveFromFolder.Object", "{http://www.alfresco.org/model/system/1.0}base.DeleteNode"),
|
||||
|
||||
// versioning services
|
||||
CAN_CHECKOUT("canCheckOut", "canCheckout.Document", CMISAccessControlService.CMIS_ALL_PERMISSION, "canCheckout.Document", "{http://www.alfresco.org/model/content/1.0}lockable.CheckOut"),
|
||||
CAN_CANCEL_CHECKOUT("canCancelCheckOut", "canCancelCheckout.Document", CMISAccessControlService.CMIS_ALL_PERMISSION, "canCancelCheckout.Document", "{http://www.alfresco.org/model/content/1.0}workingcopy.CancelCheckOut"),
|
||||
CAN_CHECKIN("canCheckIn", "canCheckin.Document", CMISAccessControlService.CMIS_ALL_PERMISSION, "canCheckin.Document", "{http://www.alfresco.org/model/content/1.0}workingcopy.CheckIn"),
|
||||
CAN_GET_ALL_VERSIONS("canGetAllVersions", "canGetAllVersions.VersionSeries", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetAllVersions.VersionSeries", "{http://www.alfresco.org/model/system/1.0}base.Read"),
|
||||
|
||||
// relationship services
|
||||
CAN_GET_OBJECT_RELATIONSHIPS("canGetObjectRelationships"),
|
||||
|
||||
// policy services
|
||||
CAN_APPLY_POLICY("canApplyPolicy", "canAddPolicy.Object", CMISAccessControlService.CMIS_WRITE_PERMISSION, "canAddPolicy.Policy", CMISAccessControlService.CMIS_READ_PERMISSION, "canAddPolicy.Object", "{http://www.alfresco.org/model/system/1.0}base.Write"),
|
||||
CAN_REMOVE_POLICY("canRemovePolicy", "canRemovePolicy.Object", CMISAccessControlService.CMIS_WRITE_PERMISSION, "canRemovePolicy.Policy", CMISAccessControlService.CMIS_READ_PERMISSION, "canRemovePolicy.Object", "{http://www.alfresco.org/model/system/1.0}base.Write"),
|
||||
CAN_GET_APPLIED_POLICIES("canGetAppliedPolicies", "canGetAppliedPolicies.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "canGetAppliedPolicies.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadProperties"),
|
||||
|
||||
// acl services
|
||||
CAN_GET_ACL("canGetACL", "canGetACL.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "canGetACL.Object", "{http://www.alfresco.org/model/system/1.0}base.ReadPermissions"),
|
||||
CAN_APPLY_ACL("canApplyACL", "canApplyACL.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "canApplyACL.Object", "{http://www.alfresco.org/model/system/1.0}base.ChangePermissions");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
private Map<String, List<String>> mapping = new HashMap<String, List<String>>();
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISAllowedActionEnum(String label, String ... keysAndPermissions)
|
||||
{
|
||||
this.label = label;
|
||||
assert(keysAndPermissions.length % 2 == 0);
|
||||
for(int i = 0; i < keysAndPermissions.length; i++)
|
||||
{
|
||||
String key = keysAndPermissions[i];
|
||||
String permission = keysAndPermissions[++i];
|
||||
List<String> permissions = mapping.get(key);
|
||||
if(permissions == null)
|
||||
{
|
||||
permissions = new ArrayList<String>(1);
|
||||
mapping.put(key, permissions);
|
||||
}
|
||||
permissions.add(permission);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getPermissionMapping()
|
||||
{
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISAllowedActionEnum> FACTORY = new EnumFactory<CMISAllowedActionEnum>(CMISAllowedActionEnum.class);
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* Enumeration of base Alfresco Object type Ids. Possible values:<br />
|
||||
* <b>DOCUMENT</b>,<br />
|
||||
* <b>FOLDER</b>,<br />
|
||||
* <b>RELATIONSHIP</b>,<br />
|
||||
* <b>POLICY</b>
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public enum CMISBaseObjectTypeIds implements EnumLabel
|
||||
{
|
||||
DOCUMENT("cmis:document"), FOLDER("cmis:folder"), RELATIONSHIP("cmis:relationship"), POLICY("cmis:policy");
|
||||
|
||||
private String label;
|
||||
|
||||
CMISBaseObjectTypeIds(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static final EnumFactory<CMISBaseObjectTypeIds> FACTORY = new EnumFactory<CMISBaseObjectTypeIds>(CMISBaseObjectTypeIds.class);
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* Enumeration of the <b>CMIS Changes Capability</b>
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public enum CMISCapabilityChanges implements EnumLabel
|
||||
{
|
||||
NONE("none"), OBJECTIDSONLY("objectidsonly");
|
||||
|
||||
private String label;
|
||||
|
||||
CMISCapabilityChanges(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static final EnumFactory<CMISCapabilityChanges> FACTORY = new EnumFactory<CMISCapabilityChanges>(CMISCapabilityChanges.class);
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Property Cardinality Enum
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public enum CMISCardinalityEnum implements EnumLabel
|
||||
{
|
||||
SINGLE_VALUED("single"),
|
||||
MULTI_VALUED("multi");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISCardinalityEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISCardinalityEnum> FACTORY = new EnumFactory<CMISCardinalityEnum>(CMISCardinalityEnum.class, null, true);
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* This class describes entry record for some <b>Change Log</b> descriptor.
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public interface CMISChangeEvent
|
||||
{
|
||||
/**
|
||||
* Gets the change type.
|
||||
*
|
||||
* @return {@link CMISChangeType} <b>enum</b> value that determines the type of current <b>Change Event</b>
|
||||
*/
|
||||
public CMISChangeType getChangeType();
|
||||
|
||||
/**
|
||||
* Gets the change time.
|
||||
*
|
||||
* @return {@link Date} value that represents time of current <b>Change Event</b>
|
||||
*/
|
||||
public Date getChangeTime();
|
||||
|
||||
/**
|
||||
* Gets the changed node (may no longer exist).
|
||||
*
|
||||
* @return the changed node
|
||||
*/
|
||||
public NodeRef getChangedNode();
|
||||
|
||||
/**
|
||||
* Gets the object id.
|
||||
*
|
||||
* @return the object id
|
||||
*/
|
||||
public String getObjectId();
|
||||
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents descriptor for some <b>Change Log Token</b>
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public interface CMISChangeLog
|
||||
{
|
||||
/**
|
||||
* @return {@link List}<{@link CMISChangeEvent}> collection that contains all available for some <b>Change Log Token</b> <b>Change Events</b> descriptors
|
||||
*/
|
||||
public List<CMISChangeEvent> getChangeEvents();
|
||||
|
||||
/**
|
||||
* @return {@link Boolean} value that determines whether repository contains any more <b>Change Events</b> after some {@link CMISChangeLogService}.{@link #getChangeEvents()}
|
||||
* invocation
|
||||
*/
|
||||
public boolean hasMoreItems();
|
||||
|
||||
/**
|
||||
* <b>Note:</b> this is optional operation and actual <b>Change Events</b> amount in collection may not be equal to result of this method invocation
|
||||
*
|
||||
* @return {@link Integer} value that determines amount of <b>Change Events</b> those were returned
|
||||
*/
|
||||
public Integer getEventCount();
|
||||
|
||||
/**
|
||||
* @return {@link String} value that represents the next generated <b>Change Log Token</b>
|
||||
*/
|
||||
public String getNextChangeToken();
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service for manipulating with <b>Change Log Events</b> by <b>Change Log Tokens</b>. Also this service exposes some methods for describing <b>Auditing</b> features
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public interface CMISChangeLogService
|
||||
{
|
||||
/**
|
||||
* @param changeLogToken - {@link String} value that represents some <b>Change Log Token</b>
|
||||
* @param maxItems - {@link Integer} value that determines required amount of entries
|
||||
* @return {@link CMISChangeLog} instance that describes entry mapped to specified <b>Change Log Token</b>
|
||||
* @throws CMISInvalidArgumentException
|
||||
*/
|
||||
public CMISChangeLog getChangeLogEvents(String changeLogToken, Integer maxItems) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @return {@link String} value that represents <b>Change Log Token</b> which is currently actual
|
||||
*/
|
||||
public String getLastChangeLogToken();
|
||||
|
||||
/**
|
||||
* Gets the change log token maxItems entries before the given one
|
||||
*
|
||||
* @param currentPageToken
|
||||
* a change log token
|
||||
* @param maxItems
|
||||
* the number of entries to skip backwards
|
||||
* @return the change log token maxItems entries before currentPageToken
|
||||
*/
|
||||
public String getPreviousPageChangeLogToken(String currentPageToken, Integer maxItems);
|
||||
|
||||
/**
|
||||
* Assuming that currentPageToken begins a page of maxItems entries, gets the token at the start of the final page.
|
||||
*
|
||||
* @param currentPageToken
|
||||
* a change log token
|
||||
* @param maxItems
|
||||
* the number of entries per page
|
||||
* @return the change log token at the start of the final page
|
||||
*/
|
||||
public String getLastPageChangeLogToken(String currentPageToken, Integer maxItems);
|
||||
|
||||
/**
|
||||
* @return {@link CMISCapabilityChanges} <b>enum</b> value that specifies currently configured <b>Auditing</b> feature mode
|
||||
*/
|
||||
public CMISCapabilityChanges getCapability();
|
||||
|
||||
/**
|
||||
* @return {@link List}<{@link CMISBaseObjectTypeIds}> collection instance that contains configured value for Changes On Type capability
|
||||
* @see CMISBaseObjectTypeIds
|
||||
*/
|
||||
public List<CMISBaseObjectTypeIds> getChangesOnTypeCapability();
|
||||
|
||||
/**
|
||||
* @return always <b>true</b>
|
||||
*/
|
||||
public boolean getChangesIncomplete();
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* Enumeration of the <b>CMIS Change Type</b>. Possible values:<br />
|
||||
* <b>CREATED</b><br />
|
||||
* <b>UPDATED</b><br />
|
||||
* <b>DELETED</b><br />
|
||||
* <b>SECURITY</b>
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public enum CMISChangeType implements EnumLabel
|
||||
{
|
||||
CREATED("created"), UPDATED("updated"), DELETED("deleted"), SECURITY("security");
|
||||
|
||||
private String label;
|
||||
|
||||
CMISChangeType(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static final EnumFactory<CMISChangeType> FACTORY = new EnumFactory<CMISChangeType>(CMISChangeType.class);
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Choice for property definitions
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISChoice
|
||||
{
|
||||
private String name;
|
||||
|
||||
Serializable value;
|
||||
|
||||
private int index;
|
||||
|
||||
private Collection<CMISChoice> choices = new HashSet<CMISChoice>();
|
||||
|
||||
public CMISChoice(String name, Serializable value, int index)
|
||||
{
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the choice
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value when chosen
|
||||
* @return
|
||||
*/
|
||||
public Serializable getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index that determined the choices position amongst it siblings
|
||||
* @return
|
||||
*/
|
||||
public int getIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sub-choices
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISChoice> getChildren()
|
||||
{
|
||||
return choices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + index;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final CMISChoice other = (CMISChoice) obj;
|
||||
if (index != other.index)
|
||||
return false;
|
||||
if (name == null)
|
||||
{
|
||||
if (other.name != null)
|
||||
return false;
|
||||
}
|
||||
else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[Choice ");
|
||||
builder.append("name=").append(getName()).append(",");
|
||||
builder.append("index=").append(getIndex()).append(",");
|
||||
builder.append("value=").append(getValue()).append(",");
|
||||
builder.append("children=").append(getChildren());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISConstraintException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = -6416548401387587007L;
|
||||
|
||||
public CMISConstraintException(String message)
|
||||
{
|
||||
super(message, "constraint", 409);
|
||||
}
|
||||
|
||||
public CMISConstraintException(Throwable cause)
|
||||
{
|
||||
super(cause, "constraint", 409);
|
||||
}
|
||||
|
||||
public CMISConstraintException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause, "constraint", 409);
|
||||
}
|
||||
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISContentAlreadyExistsException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = -3036139369370574358L;
|
||||
|
||||
public CMISContentAlreadyExistsException()
|
||||
{
|
||||
super("Content already exists", "contentAlreadyExists", 409);
|
||||
}
|
||||
|
||||
public CMISContentAlreadyExistsException(Throwable cause)
|
||||
{
|
||||
super("Content already exists", cause, "contentAlreadyExists", 409);
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Content Stream Allowed Enum
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public enum CMISContentStreamAllowedEnum implements EnumLabel
|
||||
{
|
||||
NOT_ALLOWED("notallowed"),
|
||||
ALLOWED("allowed"),
|
||||
REQUIRED("required");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISContentStreamAllowedEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISContentStreamAllowedEnum> FACTORY = new EnumFactory<CMISContentStreamAllowedEnum>(CMISContentStreamAllowedEnum.class, null, true);
|
||||
}
|
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* CMIS Property Types Enum
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public enum CMISDataTypeEnum implements EnumLabel
|
||||
{
|
||||
STRING("string")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.TEXT;
|
||||
}
|
||||
},
|
||||
DECIMAL("decimal")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.DOUBLE;
|
||||
}
|
||||
},
|
||||
INTEGER("integer")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.LONG;
|
||||
}
|
||||
},
|
||||
BOOLEAN("boolean")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.BOOLEAN;
|
||||
}
|
||||
},
|
||||
DATETIME("datetime")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.DATETIME;
|
||||
}
|
||||
},
|
||||
URI("uri")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.TEXT;
|
||||
}
|
||||
},
|
||||
ID("id")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.TEXT;
|
||||
}
|
||||
},
|
||||
HTML("html")
|
||||
{
|
||||
public QName getDefaultDataType()
|
||||
{
|
||||
return DataTypeDefinition.TEXT;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract QName getDefaultDataType();
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISDataTypeEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISDataTypeEnum> FACTORY = new EnumFactory<CMISDataTypeEnum>(CMISDataTypeEnum.class, null, true);
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.model.ContentModel;
|
||||
|
||||
/**
|
||||
* CMIS <-> Alfresco mappings
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface CMISDictionaryModel
|
||||
{
|
||||
// CMIS Type Ids
|
||||
public static CMISTypeId DOCUMENT_TYPE_ID = new CMISTypeId(CMISScope.DOCUMENT, CMISMapping.DOCUMENT_QNAME, CMISMapping.CMIS_MODEL_NS + ":" + CMISMapping.DOCUMENT_QNAME.getLocalName(), ContentModel.TYPE_CONTENT);
|
||||
public static CMISTypeId FOLDER_TYPE_ID = new CMISTypeId(CMISScope.FOLDER, CMISMapping.FOLDER_QNAME, CMISMapping.CMIS_MODEL_NS + ":" + CMISMapping.FOLDER_QNAME.getLocalName(), ContentModel.TYPE_FOLDER);
|
||||
public static CMISTypeId RELATIONSHIP_TYPE_ID = new CMISTypeId(CMISScope.RELATIONSHIP, CMISMapping.RELATIONSHIP_QNAME, CMISMapping.CMIS_MODEL_NS + ":" + CMISMapping.RELATIONSHIP_QNAME.getLocalName(), CMISMapping.RELATIONSHIP_QNAME);
|
||||
public static CMISTypeId POLICY_TYPE_ID = new CMISTypeId(CMISScope.POLICY, CMISMapping.POLICY_QNAME, CMISMapping.CMIS_MODEL_NS + ":" + CMISMapping.POLICY_QNAME.getLocalName(), CMISMapping.POLICY_QNAME);
|
||||
|
||||
// CMIS properties
|
||||
public static String PROP_OBJECT_ID = "cmis:objectId";
|
||||
public static String PROP_BASE_TYPE_ID = "cmis:baseTypeId";
|
||||
public static String PROP_OBJECT_TYPE_ID = "cmis:objectTypeId";
|
||||
public static String PROP_CREATED_BY = "cmis:createdBy";
|
||||
public static String PROP_CREATION_DATE = "cmis:creationDate";
|
||||
public static String PROP_LAST_MODIFIED_BY = "cmis:lastModifiedBy";
|
||||
public static String PROP_LAST_MODIFICATION_DATE = "cmis:lastModificationDate";
|
||||
public static String PROP_CHANGE_TOKEN = "cmis:changeToken";
|
||||
public static String PROP_NAME = "cmis:name";
|
||||
public static String PROP_IS_IMMUTABLE = "cmis:isImmutable";
|
||||
public static String PROP_IS_LATEST_VERSION = "cmis:isLatestVersion";
|
||||
public static String PROP_IS_MAJOR_VERSION = "cmis:isMajorVersion";
|
||||
public static String PROP_IS_LATEST_MAJOR_VERSION = "cmis:isLatestMajorVersion";
|
||||
public static String PROP_VERSION_LABEL = "cmis:versionLabel";
|
||||
public static String PROP_VERSION_SERIES_ID = "cmis:versionSeriesId";
|
||||
public static String PROP_IS_VERSION_SERIES_CHECKED_OUT = "cmis:isVersionSeriesCheckedOut";
|
||||
public static String PROP_VERSION_SERIES_CHECKED_OUT_BY = "cmis:versionSeriesCheckedOutBy";
|
||||
public static String PROP_VERSION_SERIES_CHECKED_OUT_ID = "cmis:versionSeriesCheckedOutId";
|
||||
public static String PROP_CHECKIN_COMMENT = "cmis:checkinComment";
|
||||
public static String PROP_CONTENT_STREAM_LENGTH = "cmis:contentStreamLength";
|
||||
public static String PROP_CONTENT_STREAM_MIME_TYPE = "cmis:contentStreamMimeType";
|
||||
public static String PROP_CONTENT_STREAM_FILENAME = "cmis:contentStreamFileName";
|
||||
public static String PROP_CONTENT_STREAM_ID = "cmis:contentStreamId";
|
||||
public static String PROP_PARENT_ID = "cmis:parentId";
|
||||
public static String PROP_PATH = "cmis:path";
|
||||
public static String PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS = "cmis:allowedChildObjectTypeIds";
|
||||
public static String PROP_SOURCE_ID = "cmis:sourceId";
|
||||
public static String PROP_TARGET_ID = "cmis:targetId";
|
||||
public static String PROP_POLICY_TEXT = "cmis:policyText";
|
||||
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Service to query the CMIS meta model
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface CMISDictionaryService
|
||||
{
|
||||
/**
|
||||
* Find type for type id
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition findType(CMISTypeId typeId);
|
||||
|
||||
/**
|
||||
* Find type for type id
|
||||
*
|
||||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition findType(String typeId);
|
||||
|
||||
/**
|
||||
* Find type for Alfresco class name. Optionally, constrain match to one of specified CMIS scopes
|
||||
*
|
||||
* @param clazz
|
||||
* @param matchingScopes
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition findTypeForClass(QName clazz, CMISScope... matchingScopes);
|
||||
|
||||
/**
|
||||
* Find a type by its query name
|
||||
*
|
||||
* @param queryName
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition findTypeByQueryName(String queryName);
|
||||
|
||||
/**
|
||||
* Find a property by its query name
|
||||
*
|
||||
* @param queryName
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyDefinition findPropertyByQueryName(String queryName);
|
||||
|
||||
/**
|
||||
* Get Base Types
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getBaseTypes();
|
||||
|
||||
/**
|
||||
* Get all Types
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllTypes();
|
||||
|
||||
/**
|
||||
* Find property. Optionally constrain match to specified type.
|
||||
*
|
||||
* @param property
|
||||
* @param matchingType
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyDefinition findProperty(QName property, CMISTypeDefinition matchingType);
|
||||
|
||||
/**
|
||||
* Find property. Optionally constrain match to specified type.
|
||||
*
|
||||
* @param property
|
||||
* @param matchingType
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyDefinition findProperty(String property, CMISTypeDefinition matchingType);
|
||||
|
||||
/**
|
||||
* Find data type
|
||||
*
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
public CMISDataTypeEnum findDataType(QName dataType);
|
||||
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISFilterNotValidException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = -1947056142715192667L;
|
||||
|
||||
public CMISFilterNotValidException(String filter)
|
||||
{
|
||||
super("Filter not valid: " + filter, "filterNotValid", 400);
|
||||
}
|
||||
|
||||
public CMISFilterNotValidException(String filter, Throwable cause)
|
||||
{
|
||||
super("Filter not valid: " + filter, cause, "filterNotValid", 400);
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISInvalidArgumentException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = -3036139369370574358L;
|
||||
|
||||
public CMISInvalidArgumentException(String message)
|
||||
{
|
||||
super(message, "invalidArgument", 400);
|
||||
}
|
||||
|
||||
public CMISInvalidArgumentException(Throwable cause)
|
||||
{
|
||||
super(cause, "invalidArgument", 400);
|
||||
}
|
||||
|
||||
public CMISInvalidArgumentException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause, "invalidArgument", 400);
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Join Enum
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public enum CMISJoinEnum implements EnumLabel
|
||||
{
|
||||
NO_JOIN_SUPPORT("none"),
|
||||
INNER_JOIN_SUPPORT("inneronly"),
|
||||
INNER_AND_OUTER_JOIN_SUPPORT("innerandouter");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISJoinEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISJoinEnum> FACTORY = new EnumFactory<CMISJoinEnum>(CMISJoinEnum.class, null, true);
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISNotSupportedException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = 3550854898281486115L;
|
||||
|
||||
public CMISNotSupportedException(String message)
|
||||
{
|
||||
super(message, "notSupported", 405);
|
||||
}
|
||||
|
||||
public CMISNotSupportedException(Throwable cause)
|
||||
{
|
||||
super(cause, "notSupported", 405);
|
||||
}
|
||||
|
||||
public CMISNotSupportedException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause, "notSupported", 405);
|
||||
}
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISObjectNotFoundException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = 1726826685938651586L;
|
||||
|
||||
public CMISObjectNotFoundException(String message)
|
||||
{
|
||||
super(message, "objectNotFound", 404);
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* CMIS Object Reference (mapping to Node Ref)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface CMISObjectReference
|
||||
{
|
||||
/**
|
||||
* @return repository reference
|
||||
*/
|
||||
public CMISRepositoryReference getRepositoryReference();
|
||||
|
||||
/**
|
||||
* @return node reference
|
||||
*/
|
||||
public NodeRef getNodeRef();
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
/**
|
||||
* A permission definition
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISPermissionDefinition
|
||||
{
|
||||
/**
|
||||
* The unique permission string (used for assignment)
|
||||
* @return the permission.
|
||||
*/
|
||||
public String getPermission();
|
||||
|
||||
/**
|
||||
* An optional permission description.
|
||||
* If not set, this defaults to the permission.
|
||||
*
|
||||
* @return the optional description.
|
||||
*/
|
||||
public String getDescription();
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISPermissionDeniedException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = 5483026490801996479L;
|
||||
|
||||
public CMISPermissionDeniedException(String message)
|
||||
{
|
||||
super(message, "permissionDenied", 403);
|
||||
}
|
||||
|
||||
public CMISPermissionDeniedException(Throwable cause)
|
||||
{
|
||||
super(cause, "permissionDenied", 403);
|
||||
}
|
||||
|
||||
public CMISPermissionDeniedException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause, "permissionDenied", 403);
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A CMIS permission mapping.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISPermissionMapping
|
||||
{
|
||||
/**
|
||||
* Get the allowed action key.
|
||||
* @return the key.
|
||||
*/
|
||||
public String getKey();
|
||||
|
||||
/**
|
||||
* Get the required permissions.
|
||||
* If the list is of zero length the action is unprotected and allowed.
|
||||
* (Disallowed actions never appear at all)
|
||||
* For one or more entries a match against any permission allws.
|
||||
*
|
||||
* @return the list of required permissions.
|
||||
*/
|
||||
public List<String> getPermissions();
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* CMIS Property Accessor (get and set property values)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface CMISPropertyAccessor
|
||||
{
|
||||
/**
|
||||
* Get the CMIS Property Name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the (directly) mapped Alfresco property (if a direct mapping exists)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
QName getMappedProperty();
|
||||
|
||||
/**
|
||||
* Get the property value for a node or an association
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Set the property value for a node
|
||||
*
|
||||
* @param nodeRef
|
||||
* @Param value
|
||||
*/
|
||||
void setValue(NodeRef nodeRef, Serializable value);
|
||||
|
||||
/**
|
||||
* Get the property value for an association
|
||||
*
|
||||
* @param nodeRef
|
||||
* @return
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef);
|
||||
}
|
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
|
||||
|
||||
/**
|
||||
* CMIS Property Definition
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface CMISPropertyDefinition
|
||||
{
|
||||
/**
|
||||
* Get Property Id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyId getPropertyId();
|
||||
|
||||
/**
|
||||
* Get Owning Type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition getOwningType();
|
||||
|
||||
/**
|
||||
* Get the query name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getQueryName();
|
||||
|
||||
/**
|
||||
* Get the display name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Get the description
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Get the property type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISDataTypeEnum getDataType();
|
||||
|
||||
/**
|
||||
* Get the cardinality
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISCardinalityEnum getCardinality();
|
||||
|
||||
/**
|
||||
* Get the choices available as values for this property TODO: not
|
||||
* implemented yet
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISChoice> getChoices();
|
||||
|
||||
/**
|
||||
* Is this a choice where a user can enter other values (ie a list with
|
||||
* common options)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOpenChoice();
|
||||
|
||||
/**
|
||||
* Is this property required?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isRequired();
|
||||
|
||||
/**
|
||||
* get the default value as a String
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultValue();
|
||||
|
||||
/**
|
||||
* Is this property updatable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISUpdatabilityEnum getUpdatability();
|
||||
|
||||
/**
|
||||
* Is this property queryable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isQueryable();
|
||||
|
||||
/**
|
||||
* Is this property orderable in queries?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOrderable();
|
||||
|
||||
/**
|
||||
* For variable length properties, get the maximum length allowed.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getMaximumLength();
|
||||
|
||||
/**
|
||||
* For Integer and Decimal properties, get the minimum value allowed
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Double getMinValue();
|
||||
|
||||
/**
|
||||
* For Integer and Decimal properties, get the maximum value allowed
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Double getMaxValue();
|
||||
|
||||
/**
|
||||
* Gets the property accessor (for reading / writing values)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyAccessor getPropertyAccessor();
|
||||
|
||||
/**
|
||||
* Gets the property Lucene builder
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyLuceneBuilder getPropertyLuceneBuilder();
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Property Id
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISPropertyId implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 4094778633095367606L;
|
||||
|
||||
// Id properties
|
||||
private QName propertyQName;
|
||||
private String propertyId;
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param propertyName
|
||||
* @param propertyId
|
||||
* @param internalQName
|
||||
*/
|
||||
public CMISPropertyId(QName propertyQName, String propertyId)
|
||||
{
|
||||
this.propertyQName = propertyQName;
|
||||
this.propertyId = propertyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get property id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get property local name
|
||||
* @return
|
||||
*/
|
||||
public String getLocalName()
|
||||
{
|
||||
return propertyQName.getLocalName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get property local namespace
|
||||
* @return
|
||||
*/
|
||||
public String getLocalNamespace()
|
||||
{
|
||||
return propertyQName.getNamespaceURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Alfresco model QName associated with the property
|
||||
*
|
||||
* @return alfresco QName
|
||||
*/
|
||||
public QName getQName()
|
||||
{
|
||||
return propertyQName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((propertyQName == null) ? 0 : propertyQName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final CMISPropertyId other = (CMISPropertyId) obj;
|
||||
if (propertyQName == null)
|
||||
{
|
||||
if (other.propertyQName != null)
|
||||
return false;
|
||||
}
|
||||
else if (!propertyQName.equals(other.propertyQName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Join Enum
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public enum CMISQueryEnum implements EnumLabel
|
||||
{
|
||||
NONE("none"),
|
||||
METADATA_ONLY("metadataonly"),
|
||||
FULLTEXT_ONLY("fulltextonly"),
|
||||
BOTH_SEPERATE("bothseparate"),
|
||||
BOTH_COMBINED("bothcombined");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISQueryEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISQueryEnum> FACTORY = new EnumFactory<CMISQueryEnum>(CMISQueryEnum.class, null, true);
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISQueryException extends AlfrescoRuntimeException
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8281715613061152219L;
|
||||
|
||||
/**
|
||||
* @param msgId
|
||||
*/
|
||||
public CMISQueryException(String msgId)
|
||||
{
|
||||
super(msgId);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msgId
|
||||
* @param msgParams
|
||||
*/
|
||||
public CMISQueryException(String msgId, Object[] msgParams)
|
||||
{
|
||||
super(msgId, msgParams);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msgId
|
||||
* @param cause
|
||||
*/
|
||||
public CMISQueryException(String msgId, Throwable cause)
|
||||
{
|
||||
super(msgId, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msgId
|
||||
* @param msgParams
|
||||
* @param cause
|
||||
*/
|
||||
public CMISQueryException(String msgId, Object[] msgParams, Throwable cause)
|
||||
{
|
||||
super(msgId, msgParams, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryOptions;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.LimitBy;
|
||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* The options for a CMIS query
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class CMISQueryOptions extends QueryOptions
|
||||
{
|
||||
public enum CMISQueryMode
|
||||
{
|
||||
CMS_STRICT, CMS_WITH_ALFRESCO_EXTENSIONS ;
|
||||
}
|
||||
|
||||
|
||||
private CMISQueryMode queryMode = CMISQueryMode.CMS_STRICT;
|
||||
|
||||
|
||||
public static CMISQueryOptions create(SearchParameters searchParameters)
|
||||
{
|
||||
String sql = searchParameters.getQuery();
|
||||
|
||||
CMISQueryOptions options = new CMISQueryOptions(sql, searchParameters.getStores().get(0));
|
||||
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
||||
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
||||
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
||||
options.setSkipCount(searchParameters.getSkipCount());
|
||||
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
||||
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
||||
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
||||
{
|
||||
options.setMaxItems(searchParameters.getLimit());
|
||||
}
|
||||
else
|
||||
{
|
||||
options.setMaxItems(searchParameters.getMaxItems());
|
||||
}
|
||||
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
||||
options.setLocales(searchParameters.getLocales());
|
||||
options.setStores(searchParameters.getStores());
|
||||
options.setUseInMemorySort(searchParameters.getUseInMemorySort());
|
||||
options.setMaxRawResultSetSizeForInMemorySort(searchParameters.getMaxRawResultSetSizeForInMemorySort());
|
||||
//options.setQuery(); Done on conbstruction
|
||||
//options.setQueryMode(); Should set afterwards
|
||||
options.setQueryParameterDefinitions(searchParameters.getQueryParameterDefinitions());
|
||||
options.setDefaultFieldName(searchParameters.getDefaultFieldName());
|
||||
options.setBulkFetchEnabled(searchParameters.isBulkFetchEnabled());
|
||||
options.setExcludeTenantFilter(searchParameters.getExcludeTenantFilter());
|
||||
options.setSinceTxId(searchParameters.getSinceTxId());
|
||||
return options;
|
||||
}
|
||||
/**
|
||||
* Create a CMISQueryOptions instance with the default options other than the query and store ref.
|
||||
* The query will be run using the locale returned by I18NUtil.getLocale()
|
||||
*
|
||||
* @param query - the query to run
|
||||
* @param storeRef - the store against which to run the query
|
||||
*/
|
||||
public CMISQueryOptions(String query, StoreRef storeRef)
|
||||
{
|
||||
this(query, storeRef, I18NUtil.getLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CMISQueryOptions instance with the default options other than the query, store ref and locale.
|
||||
*
|
||||
* @param query - the query to run
|
||||
* @param storeRef - the store against which to run the query
|
||||
*/
|
||||
public CMISQueryOptions(String query, StoreRef storeRef, Locale locale)
|
||||
{
|
||||
super(query, storeRef, locale);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the query mode.
|
||||
*
|
||||
* @return the queryMode
|
||||
*/
|
||||
public CMISQueryMode getQueryMode()
|
||||
{
|
||||
return queryMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the query mode.
|
||||
*
|
||||
* @param queryMode the queryMode to set
|
||||
*/
|
||||
public void setQueryMode(CMISQueryMode queryMode)
|
||||
{
|
||||
this.queryMode = queryMode;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public SearchParameters getAsSearchParmeters()
|
||||
{
|
||||
SearchParameters searchParameters = new SearchParameters();
|
||||
searchParameters.setDefaultFieldName(this.getDefaultFieldName());
|
||||
searchParameters.setDefaultFTSFieldConnective(this.getDefaultFTSFieldConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
|
||||
searchParameters.setDefaultFTSOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
|
||||
searchParameters.setDefaultOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
|
||||
searchParameters.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
|
||||
if(this.getMaxItems() > 0)
|
||||
{
|
||||
searchParameters.setLimit(this.getMaxItems());
|
||||
searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
|
||||
searchParameters.setMaxItems(this.getMaxItems());
|
||||
}
|
||||
searchParameters.setMaxPermissionChecks(this.getMaxPermissionChecks());
|
||||
searchParameters.setMaxPermissionCheckTimeMillis(this.getMaxPermissionCheckTimeMillis());
|
||||
searchParameters.setMlAnalaysisMode(this.getMlAnalaysisMode());
|
||||
//searchParameters.setNamespace() TODO: Fix
|
||||
//searchParameters.setPermissionEvaluation()
|
||||
searchParameters.setQuery(this.getQuery());
|
||||
searchParameters.setSkipCount(this.getSkipCount());
|
||||
//searchParameters.addAllAttribute()
|
||||
for(Locale locale : this.getLocales())
|
||||
{
|
||||
searchParameters.addLocale(locale);
|
||||
}
|
||||
for(QueryParameterDefinition queryParameterDefinition: this.getQueryParameterDefinitions())
|
||||
{
|
||||
searchParameters.addQueryParameterDefinition(queryParameterDefinition);
|
||||
}
|
||||
//searchParameters.addQueryTemplate(name, template)
|
||||
//searchParameters.addSort()
|
||||
for(StoreRef storeRef : this.getStores())
|
||||
{
|
||||
searchParameters.addStore(storeRef);
|
||||
}
|
||||
//searchParameters.addTextAttribute()
|
||||
searchParameters.setBulkFetchEnabled(isBulkFetchEnabled());
|
||||
searchParameters.setQueryConsistency(this.getQueryConsistency());
|
||||
return searchParameters;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
|
||||
/**
|
||||
* Support to execute CMIS queries
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISQueryService
|
||||
{
|
||||
/**
|
||||
* Execute a CMIS query as defined by options
|
||||
*
|
||||
* @param options
|
||||
* @return a result set
|
||||
*/
|
||||
public CMISResultSet query(CMISQueryOptions options);
|
||||
|
||||
/**
|
||||
* Execute a CMIS query with all the default options;
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
public CMISResultSet query(String query);
|
||||
|
||||
|
||||
/**
|
||||
* Get the query support level
|
||||
*/
|
||||
public CMISQueryEnum getQuerySupport();
|
||||
|
||||
/**
|
||||
* Get the join support level in queries.
|
||||
*/
|
||||
public CMISJoinEnum getJoinSupport();
|
||||
|
||||
/**
|
||||
* Can you query Private Working Copies of a document.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getPwcSearchable();
|
||||
|
||||
/**
|
||||
* Can you query non-latest versions of a document.
|
||||
* The current latest version is always searchable according to the type definition.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getAllVersionsSearchable();
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Types Filter Enum
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public enum CMISRelationshipDirectionEnum implements EnumLabel
|
||||
{
|
||||
SOURCE("source"),
|
||||
TARGET("target"),
|
||||
EITHER("either");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISRelationshipDirectionEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISRelationshipDirectionEnum> FACTORY = new EnumFactory<CMISRelationshipDirectionEnum>(CMISRelationshipDirectionEnum.class, SOURCE);
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Relationship Reference (mapping to Association Ref)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface CMISRelationshipReference
|
||||
{
|
||||
/**
|
||||
* @return repository reference
|
||||
*/
|
||||
public CMISRepositoryReference getRepositoryReference();
|
||||
|
||||
/**
|
||||
* @return association reference
|
||||
*/
|
||||
public AssociationRef getAssocRef();
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* CMIS Document Rendition
|
||||
*
|
||||
* @author Stas Sokolovsky
|
||||
*/
|
||||
public interface CMISRendition
|
||||
{
|
||||
/**
|
||||
* Gets the thumbnail node reference
|
||||
*/
|
||||
public NodeRef getNodeRef();
|
||||
|
||||
/**
|
||||
* Get the rendition stream id
|
||||
* @return
|
||||
*/
|
||||
public String getStreamId();
|
||||
|
||||
/**
|
||||
* Get the MIME type of the rendition stream.
|
||||
* @return
|
||||
*/
|
||||
public String getMimeType();
|
||||
|
||||
/**
|
||||
* Get rendition kind.
|
||||
* @return
|
||||
*/
|
||||
public String getKind();
|
||||
|
||||
/**
|
||||
* Get the height of image. Typically used for ‘image’ renditions (expressed as pixels).
|
||||
* @return
|
||||
*/
|
||||
public Integer getHeight();
|
||||
|
||||
/**
|
||||
* Get the width of image. Typically used for ‘image’ renditions (expressed as pixels).
|
||||
* @return
|
||||
*/
|
||||
public Integer getWidth();
|
||||
|
||||
/**
|
||||
* Get a human readable information about the rendition.
|
||||
* @return
|
||||
*/
|
||||
public String getTitle();
|
||||
|
||||
/**
|
||||
* Get the length of the rendition stream in bytes.
|
||||
* @return
|
||||
*/
|
||||
public Integer getLength();
|
||||
|
||||
/**
|
||||
* Get the rendition document id. If specified, then the rendition can also be accessed
|
||||
* as a document object in the CMIS services.
|
||||
* @return
|
||||
*/
|
||||
public String getRenditionDocumentId();
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Service to retrieving renditions of document
|
||||
*
|
||||
* @author Stas Sokolovsky
|
||||
*/
|
||||
public interface CMISRenditionService
|
||||
{
|
||||
/**
|
||||
* Get renditions for a document.
|
||||
*
|
||||
* @param node node reference of document
|
||||
* @param renditionFilter renditions filter
|
||||
* @return list of renditions
|
||||
* @throws CMISFilterNotValidException
|
||||
*/
|
||||
public List<CMISRendition> getRenditions(NodeRef node, String renditionFilter) throws CMISFilterNotValidException;
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Repository Reference (mapping to Store Ref)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public interface CMISRepositoryReference
|
||||
{
|
||||
/**
|
||||
* @return store reference
|
||||
*/
|
||||
public abstract StoreRef getStoreRef();
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.search.ResultSetSPI;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A CMIS result set
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface CMISResultSet extends ResultSetSPI<CMISResultSetRow, CMISResultSetMetaData>
|
||||
{
|
||||
/**
|
||||
* Get the result set meta-data.
|
||||
* @return the metadata
|
||||
*/
|
||||
public CMISResultSetMetaData getMetaData();
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of rows in this result set.
|
||||
*
|
||||
* This will be less than or equal to the maximum number of rows requested or
|
||||
* the full length if no restriction on length is specified.
|
||||
*
|
||||
* If a skip count is given, the length represents the number of results
|
||||
* after the skip count and does not include the items skipped.
|
||||
*
|
||||
* @return the length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.search.ResultSetColumn;
|
||||
|
||||
|
||||
/**
|
||||
* The column meta data for a result set
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISResultSetColumn extends ResultSetColumn
|
||||
{
|
||||
/**
|
||||
* The property definition if there is one for the column
|
||||
* @return - the property definition or null if it does not make sense for the column
|
||||
*/
|
||||
public CMISPropertyDefinition getCMISPropertyDefinition();
|
||||
|
||||
/**
|
||||
* The type of the column
|
||||
* @return - the CMIS type for the column
|
||||
*/
|
||||
public CMISDataTypeEnum getCMISDataType();
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.search.ResultSetMetaData;
|
||||
|
||||
|
||||
/**
|
||||
* The meta data associated with a result set
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISResultSetMetaData extends ResultSetMetaData
|
||||
{
|
||||
/**
|
||||
* The selector meta-data.
|
||||
* @return - the selector meta-data.
|
||||
*/
|
||||
public CMISResultSetSelector[] getSelectors();
|
||||
|
||||
/**
|
||||
* The column meta-data.
|
||||
* @return - the column meta-data.
|
||||
*/
|
||||
public CMISResultSetColumn[] getColumns();
|
||||
|
||||
/**
|
||||
* Get the query options used to create this result set
|
||||
* @return the query options
|
||||
*/
|
||||
public CMISQueryOptions getQueryOptions();
|
||||
|
||||
/**
|
||||
* Get the names of the selectors.
|
||||
* @return - the selector names.
|
||||
*/
|
||||
public String[] getSelectorNames();
|
||||
|
||||
/**
|
||||
* Get the column names.
|
||||
* @return - the names of the columns.
|
||||
*/
|
||||
public String[] getColumnNames();
|
||||
|
||||
/**
|
||||
* Get the selector meta-data by name.
|
||||
* @param name
|
||||
* @return - the selector meta-data.
|
||||
*/
|
||||
public CMISResultSetSelector getSelector(String name);
|
||||
|
||||
/**
|
||||
* Get the column meta-data by column name.
|
||||
* @param name
|
||||
* @return - the column meta-data.
|
||||
*/
|
||||
public CMISResultSetColumn getColumn(String name);
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
|
||||
/**
|
||||
* A row in a CMISResultSet
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISResultSetRow extends ResultSetRow
|
||||
{
|
||||
/**
|
||||
* Get the result set for which this row is a member.
|
||||
* @return - the result set.
|
||||
*/
|
||||
public CMISResultSet getCMISResultSet();
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.service.cmr.search.ResultSetSelector;
|
||||
|
||||
|
||||
/**
|
||||
* The meta-data for a result set selector.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISResultSetSelector extends ResultSetSelector
|
||||
{
|
||||
/**
|
||||
* Get the type definition for the selector.
|
||||
* @return - the CMIS type definition.
|
||||
*/
|
||||
public CMISTypeDefinition getTypeDefinition();
|
||||
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISRuntimeException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = 18549812596930942L;
|
||||
|
||||
public CMISRuntimeException(String message)
|
||||
{
|
||||
super(message, "runtime", 500);
|
||||
}
|
||||
|
||||
public CMISRuntimeException(Throwable cause)
|
||||
{
|
||||
super(cause, "runtime", 500);
|
||||
}
|
||||
|
||||
public CMISRuntimeException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause, "runtime", 500);
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
|
||||
/**
|
||||
* The scope for a CMIS name
|
||||
*
|
||||
* Alfresco has different name spaces for relationships and objects.
|
||||
* This scope resolves any ambiguity.
|
||||
* This ambiguity is resolved in the CMIS type id mapping.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public enum CMISScope implements EnumLabel
|
||||
{
|
||||
OBJECT ("O"),
|
||||
RELATIONSHIP ("R"),
|
||||
DOCUMENT ("D"),
|
||||
FOLDER ("F"),
|
||||
POLICY ("P"),
|
||||
UNKNOWN ("U");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISScope(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISScope> FACTORY = new EnumFactory<CMISScope>(CMISScope.class);
|
||||
}
|
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
/**
|
||||
* A base class for all exceptions that map to CMIS SOAP faults / HTTP error codes. Intentionally a checked
|
||||
* non-RuntimeException so that the faults codes are propagated and signalled correctly.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public abstract class CMISServiceException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 8220732267294509499L;
|
||||
|
||||
/** The fault name, as per the CMIS spec. */
|
||||
private final String faultName;
|
||||
|
||||
/** The status code, as per the CMIS REST binding. */
|
||||
private final int statusCode;
|
||||
|
||||
/**
|
||||
* Instantiates a new CMIS Service exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param faultName
|
||||
* the fault name, as per the CMIS spec
|
||||
* @param statusCode
|
||||
* the status code, as per the CMIS REST binding
|
||||
*/
|
||||
public CMISServiceException(String message, String faultName, int statusCode)
|
||||
{
|
||||
super(message);
|
||||
this.faultName = faultName;
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new CMIS Service exception.
|
||||
*
|
||||
* @param cause
|
||||
* the cause
|
||||
* @param faultName
|
||||
* the fault name, as per the CMIS spec
|
||||
* @param statusCode
|
||||
* the status code, as per the CMIS REST binding
|
||||
*/
|
||||
public CMISServiceException(Throwable cause, String faultName, int errorCode)
|
||||
{
|
||||
this(cause.getMessage(), cause, faultName, errorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new CMIS Service exception.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
* @param cause
|
||||
* the cause
|
||||
* @param faultName
|
||||
* the fault name, as per the CMIS spec
|
||||
* @param statusCode
|
||||
* the status code, as per the CMIS REST binding
|
||||
*/
|
||||
public CMISServiceException(String message, Throwable cause, String faultName, int errorCode)
|
||||
{
|
||||
super(message, cause);
|
||||
this.faultName = faultName;
|
||||
this.statusCode = errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fault name.
|
||||
*
|
||||
* @return the fault name
|
||||
*/
|
||||
public String getFaultName()
|
||||
{
|
||||
return faultName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status code.
|
||||
*
|
||||
* @return the status code
|
||||
*/
|
||||
public int getStatusCode()
|
||||
{
|
||||
return this.statusCode;
|
||||
}
|
||||
}
|
@@ -1,893 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Services.
|
||||
*
|
||||
* @author davidc
|
||||
* @author dward
|
||||
*/
|
||||
public interface CMISServices
|
||||
{
|
||||
/**
|
||||
* The prefix we give to association object IDs.
|
||||
*/
|
||||
public static final String ASSOC_ID_PREFIX = "assoc:";
|
||||
|
||||
/**
|
||||
* Gets the supported CMIS Version
|
||||
*
|
||||
* @return version of CMIS specification supported
|
||||
*/
|
||||
public String getCMISVersion();
|
||||
|
||||
/**
|
||||
* Gets the supported CMIS Specification Title
|
||||
*
|
||||
* @return CMIS pecification Title
|
||||
*/
|
||||
public String getCMISSpecTitle();
|
||||
|
||||
/**
|
||||
* Gets the default root node path
|
||||
*
|
||||
* @return root node path
|
||||
*/
|
||||
public String getDefaultRootPath();
|
||||
|
||||
/**
|
||||
* Gets the default root node ref
|
||||
*
|
||||
* @return root node ref
|
||||
*/
|
||||
public NodeRef getDefaultRootNodeRef();
|
||||
|
||||
/**
|
||||
* Gets the default store ref
|
||||
*
|
||||
* @return store ref
|
||||
*/
|
||||
public StoreRef getDefaultRootStoreRef();
|
||||
|
||||
/**
|
||||
* Finds a NodeRef given a repository reference
|
||||
*
|
||||
* @param referenceType node, path
|
||||
* @param reference node => id, path => path
|
||||
* @return nodeRef (or null, if not found)
|
||||
*/
|
||||
public NodeRef getNode(String referenceType, String[] reference);
|
||||
|
||||
/**
|
||||
* Gets a map of node attributes relating to renditions.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node ref
|
||||
* @param renditionFilter
|
||||
* the rendition filter
|
||||
* @return the attribute map
|
||||
* @throws CMISFilterNotValidException
|
||||
* if the rendition filter is invalid
|
||||
*/
|
||||
public Map<String, Object> getRenditions(NodeRef nodeRef, String renditionFilter)
|
||||
throws CMISFilterNotValidException;
|
||||
|
||||
/**
|
||||
* Get node children
|
||||
*
|
||||
* @param parent
|
||||
* parent node
|
||||
* @param typesFilter
|
||||
* types filter
|
||||
* @param orderBy
|
||||
* comma-separated list of sort names and the ascending modifier "ASC" or the descending modifier "DESC"
|
||||
* for each sort name
|
||||
* @return children of node
|
||||
*/
|
||||
public NodeRef[] getChildren(NodeRef parent, CMISTypesFilterEnum typesFilter, String orderBy)
|
||||
throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get node children
|
||||
*
|
||||
* @param parent
|
||||
* parent node
|
||||
* @param typesFilter
|
||||
* types filter
|
||||
* @param maxItems
|
||||
* number of items (in page)
|
||||
* @param skipCount
|
||||
* number of items to skip (page starts at next item)
|
||||
* @param orderBy
|
||||
* comma-separated list of sort names and the ascending modifier "ASC" or the descending modifier "DESC"
|
||||
* for each sort name
|
||||
* @return children of node
|
||||
*/
|
||||
public PagingResults<FileInfo> getChildren(NodeRef parent, CMISTypesFilterEnum typesFilter, BigInteger maxItems, BigInteger skipCount, String orderBy)
|
||||
throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Query for checked out items
|
||||
*
|
||||
* @param username
|
||||
* for user
|
||||
* @param folder
|
||||
* (optional) within folder
|
||||
* @param includeDescendants
|
||||
* true => include descendants of folder, false => only children of folder
|
||||
* @param orderBy
|
||||
* comma-separated list of query names and the ascending modifier "ASC" or the descending modifier "DESC"
|
||||
* for each query name
|
||||
* @return checked out items
|
||||
*/
|
||||
public NodeRef[] getCheckedOut(String username, NodeRef folder, boolean includeDescendants, String orderBy)
|
||||
throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Query for relationships.
|
||||
*
|
||||
* @param relDef
|
||||
* type of relationship to query (or null, for all relationships)
|
||||
* @param includeSubTypes
|
||||
* the include sub types
|
||||
* @param direction
|
||||
* limit direction of relationships to query (or null, for both directions)
|
||||
* @param node
|
||||
* the node
|
||||
* @return relationships
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public AssociationRef[] getRelationships(NodeRef node, CMISTypeDefinition relDef, boolean includeSubTypes, CMISRelationshipDirectionEnum direction) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get a single property belonging to the node's type.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return value
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Serializable getProperty(NodeRef nodeRef, String propertyName) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get a single property, optionally constrained to a given node type or aspect
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node
|
||||
* @param typeDef
|
||||
* the node type or aspect or <code>null</code> if any property can be returned
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return value
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Serializable getProperty(NodeRef nodeRef, CMISTypeDefinition typeDef, String propertyName)
|
||||
throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get a single property for an association.
|
||||
*
|
||||
* @param assocRef
|
||||
* the association
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @return value
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Serializable getProperty(AssociationRef assocRef, String propertyName) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get all properties of a node's type.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node ref
|
||||
* @return the properties
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Map<String, Serializable> getProperties(NodeRef nodeRef) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get all properties of an association's type.
|
||||
*
|
||||
* @param assocRef
|
||||
* the association
|
||||
* @return the properties
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Map<String, Serializable> getProperties(AssociationRef assocRef) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Get all of a node's values for the properties in the given type or aspect.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node ref
|
||||
* @param typeDef
|
||||
* the type or aspect definition
|
||||
* @return the properties
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Map<String, Serializable> getProperties(NodeRef nodeRef, CMISTypeDefinition typeDef)
|
||||
throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Gets the aspects applied to a node.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node ref
|
||||
* @return the aspect definitions
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public Set<CMISTypeDefinition> getAspects(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Set a single property belonging to the node's type.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node ref
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISConstraintException
|
||||
* if the property cannot be set
|
||||
*/
|
||||
public void setProperty(NodeRef nodeRef, String propertyName, Serializable value)
|
||||
throws CMISInvalidArgumentException, CMISConstraintException;
|
||||
|
||||
/**
|
||||
* Set a single property, optionally constrained to a given node type or aspect
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node ref
|
||||
* @param typeDef
|
||||
* the node type or aspect or <code>null</code> if any valid property should be set (corresponding aspect
|
||||
* added automatically).
|
||||
* @param propertyName
|
||||
* the property name
|
||||
* @param value
|
||||
* the value
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISConstraintException
|
||||
* if the property cannot be set
|
||||
*/
|
||||
public void setProperty(NodeRef nodeRef, CMISTypeDefinition typeDef, String propertyName, Serializable value)
|
||||
throws CMISInvalidArgumentException, CMISConstraintException;
|
||||
|
||||
/**
|
||||
* Sets the aspects on a node (Alfresco extension).
|
||||
*
|
||||
* @param node
|
||||
* the node
|
||||
* @param aspectsToRemove
|
||||
* the aspects to remove
|
||||
* @param aspectsToAdd
|
||||
* the aspects to add
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public void setAspects(NodeRef node, Iterable<String> aspectsToRemove, Iterable<String> aspectsToAdd)
|
||||
throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Applies a versioning state to a new node, potentially resulting in a new node.
|
||||
*
|
||||
* @param source
|
||||
* the node
|
||||
* @param versioningState
|
||||
* the versioning state
|
||||
* @return the node to write changes to
|
||||
* @throws CMISConstraintException
|
||||
* if it's not possible to apply the state
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public NodeRef applyVersioningState(NodeRef source, CMISVersioningStateEnum versioningState)
|
||||
throws CMISConstraintException, CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Gets a readable object of a required type from an object ID. The object may be immutable. Note that version
|
||||
* history nodes can be returned as Versions or Nodes.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param requiredType
|
||||
* the required type (NodeRef.class, Version.class, AssociationRef.class or Object.class)
|
||||
* @return the readable object
|
||||
* @throws CMISConstraintException
|
||||
* if the object can't be returned as the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public <T> T getReadableObject(String objectId, Class<T> requiredType) throws CMISConstraintException,
|
||||
CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException,
|
||||
CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets an object or a required type from an object ID. The object's mutability and versioning state will be
|
||||
* validated as required.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param requiredType
|
||||
* the required type (NodeRef.class, Version.class, AssociationRef.class or Object.class)
|
||||
* @param forUpdate
|
||||
* Do we require to write to this object? If <code>true</code> then the object must not be checked out
|
||||
* and must not be a version history node unless the required type is assignable from Version.class.
|
||||
* @param isVersionable
|
||||
* Should the object be versionable?
|
||||
* @param isPwc
|
||||
* If isVersionable is <code>true</code> then the object should either be or not be a private working
|
||||
* copy, as indicated by this flag
|
||||
* @return the object
|
||||
* @throws CMISConstraintException
|
||||
* if the object can't be returned as the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public <T> T getObject(String objectId, Class<T> requiredType, boolean forUpdate, boolean isVersionable,
|
||||
boolean isPwc) throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException,
|
||||
CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets the version series of an object.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param requiredType
|
||||
* the required type (NodeRef.class, Version.class or AssociationRef.class)
|
||||
* @param isVersionable
|
||||
* Should the object be versionable?
|
||||
* @return the version series
|
||||
* @throws CMISConstraintException
|
||||
* if the object can't be returned as the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public <T> T getVersionSeries(String objectId, Class<T> requiredType, boolean isVersionable)
|
||||
throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException,
|
||||
CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets a folder from an object ID.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @return the folder
|
||||
* @throws CMISConstraintException
|
||||
* if the object can't be returned as the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public NodeRef getFolder(String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets parent of a folder.
|
||||
*
|
||||
* @param folderId
|
||||
* the folder id
|
||||
* @return the folder parent
|
||||
* @throws CMISConstraintException
|
||||
* if the object can't be returned as the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public NodeRef getFolderParent(String folderId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets the type definition for a node.
|
||||
*
|
||||
* @param nodeRef
|
||||
* the node
|
||||
* @return the type definition
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public CMISTypeDefinition getTypeDefinition(NodeRef nodeRef) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Gets the type definition for an association.
|
||||
*
|
||||
* @param associationRef
|
||||
* the association
|
||||
* @return the type definition
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public CMISTypeDefinition getTypeDefinition(AssociationRef associationRef) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Gets the type definition for a given type ID.
|
||||
*
|
||||
* @param typeId
|
||||
* the type id
|
||||
* @return the type definition
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public CMISTypeDefinition getTypeDefinition(String typeId) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Gets the type definition for a given object.
|
||||
*
|
||||
* @param object
|
||||
* the object
|
||||
* @return the type definition
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
*/
|
||||
public CMISTypeDefinition getTypeDefinition(Object object) throws CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Gets the CMIS base types.
|
||||
*
|
||||
* @return the base types
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getBaseTypes();
|
||||
|
||||
/**
|
||||
* Checks out an object.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @return the resulting private working copy node
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public NodeRef checkOut(String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Checks in a private working copy.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id of the private working copy
|
||||
* @param checkinComment
|
||||
* the checkin comment
|
||||
* @param isMajor
|
||||
* Is this a major version?
|
||||
* @return the checked in node
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public NodeRef checkIn(String objectId, String checkinComment, boolean isMajor) throws CMISConstraintException,
|
||||
CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException,
|
||||
CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Cancels check out of a private working copy.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id of the private working copy
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public void cancelCheckOut(String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets all versions of an object.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @return the all versions
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public List<NodeRef> getAllVersions(String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets the latest version of an object and optionally the latest major version.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param major
|
||||
* Should we return the latest major version?
|
||||
* @return the latest version
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public NodeRef getLatestVersion(String objectId, boolean major) throws CMISConstraintException,
|
||||
CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException,
|
||||
CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Deletes a folder and its children, without raising any exceptions.
|
||||
*
|
||||
* @param objectId
|
||||
* the folder's object id
|
||||
* @param continueOnFailure
|
||||
* should we continue if an error occurs with one of the children?
|
||||
* @param unfile
|
||||
* should we remove non-primary associations to nodes rather than delete them?
|
||||
* @param deleteAllVersions
|
||||
* should we delete all the versions of the documents we delete?
|
||||
* @return list of object IDs of the children we failed to delete
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public List<String> deleteTree(String objectId, boolean continueOnFailure, boolean unfile, boolean deleteAllVersions)
|
||||
throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException,
|
||||
CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Deletes a folder and its children, raising an exception for the last error encountered.
|
||||
*
|
||||
* @param objectId
|
||||
* the folder's object id
|
||||
* @param continueOnFailure
|
||||
* should we continue if an error occurs with one of the children?
|
||||
* @param unfile
|
||||
* should we remove non-primary associations to nodes rather than delete them?
|
||||
* @param deleteAllVersions
|
||||
* should we delete all the versions of the nodes we delete?
|
||||
* @return list of object IDs of the children we failed to delete
|
||||
* @throws CMISServiceException
|
||||
* the last error encountered
|
||||
*/
|
||||
public void deleteTreeReportLastError(String objectId, boolean continueOnFailure, boolean unfile,
|
||||
boolean deleteAllVersions) throws CMISServiceException;
|
||||
|
||||
/**
|
||||
* Deletes a document's content stream.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id of the document
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
*/
|
||||
public void deleteContentStream(String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Deletes an object.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param allVersions
|
||||
* if the object is a document, should we delete all versions?
|
||||
* @throws CMISConstraintException
|
||||
* if the object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if the object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if the object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to the object is denied
|
||||
* @throws CMISRuntimeException
|
||||
* on other exceptions
|
||||
*/
|
||||
public void deleteObject(String objectId, boolean allVersions) throws CMISConstraintException,
|
||||
CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException,
|
||||
CMISPermissionDeniedException, CMISRuntimeException, CMISServiceException;
|
||||
|
||||
/**
|
||||
* Adds a secondary child association to an object from a folder.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param folderId
|
||||
* the folder id
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
*/
|
||||
public void addObjectToFolder(String objectId, String folderId) throws CMISConstraintException,
|
||||
CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException,
|
||||
CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Removes a secondary child association to an object from a folder.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param folderId
|
||||
* the folder id
|
||||
* @throws CMISNotSupportedException
|
||||
* if the child association is primary
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
*/
|
||||
public void removeObjectFromFolder(String objectId, String folderId) throws CMISNotSupportedException,
|
||||
CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException,
|
||||
CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Moves an object from one folder to another.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param targetFolderId
|
||||
* the target folder id
|
||||
* @param sourceFolderId
|
||||
* the source folder id
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
*/
|
||||
public void moveObject(String objectId, String targetFolderId, String sourceFolderId)
|
||||
throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException,
|
||||
CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Sets the content stream on an object.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param propertyQName
|
||||
* the property q name
|
||||
* @param overwriteFlag
|
||||
* the overwrite flag
|
||||
* @param contentStream
|
||||
* the content stream
|
||||
* @param mimeType
|
||||
* the mime type
|
||||
* @return <code>true</code> if content was overwritten
|
||||
* @throws CMISContentAlreadyExistsException
|
||||
* if overwrite was <code>false</code> and content already existed
|
||||
* @throws CMISStreamNotSupportedException
|
||||
* if the object's type definition does not allow a content stream
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
*/
|
||||
public boolean setContentStream(String objectId, QName propertyQName, boolean overwriteFlag,
|
||||
InputStream contentStream, String mimeType) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISContentAlreadyExistsException, CMISStreamNotSupportedException,
|
||||
CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Creates a policy object of the specified type, and optionally adds the policy to a folder. Currently no policy
|
||||
* types can be created in Alfresco.
|
||||
*
|
||||
* @param properties
|
||||
* CMIS properties
|
||||
* @param folderId
|
||||
* parent folder for this new policy
|
||||
* @param policies
|
||||
* the policies
|
||||
* @return Id of the created policy object
|
||||
* @throws CMISConstraintException
|
||||
* if there is a problem with the supplied properties
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISRuntimeException
|
||||
* on other exceptions
|
||||
*/
|
||||
public String createPolicy(Map<String, Serializable> properties, String folderId, List<String> policies)
|
||||
throws CMISConstraintException, CMISRuntimeException, CMISInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Applies a policy object to a target object.
|
||||
*
|
||||
* @param policyId
|
||||
* policy Id
|
||||
* @param objectId
|
||||
* target object Id
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
*/
|
||||
public void applyPolicy(String policyId, String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Gets the list of policy objects currently applied to a target object.
|
||||
*
|
||||
* @param objectId
|
||||
* the object id
|
||||
* @param filter
|
||||
* property filter
|
||||
* @return the applied policies
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
* @throws CMISFilterNotValidException
|
||||
* if the property filter is invalid
|
||||
*/
|
||||
public List<CMISTypeDefinition> getAppliedPolicies(String objectId, String filter) throws CMISConstraintException,
|
||||
CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException,
|
||||
CMISPermissionDeniedException, CMISFilterNotValidException;
|
||||
|
||||
/**
|
||||
* Removes a previously applied policy from a target object. The policy object is not deleted, and may still be
|
||||
* applied to other objects.
|
||||
*
|
||||
* @param policyId
|
||||
* policy Id
|
||||
* @param objectId
|
||||
* target object Id.
|
||||
* @throws CMISConstraintException
|
||||
* if an object isn't of the right type
|
||||
* @throws CMISVersioningException
|
||||
* if an object's versioning state isn't as expected
|
||||
* @throws CMISObjectNotFoundException
|
||||
* if an object does not exist
|
||||
* @throws CMISInvalidArgumentException
|
||||
* if an argument is invalid
|
||||
* @throws CMISPermissionDeniedException
|
||||
* if access to an object is denied
|
||||
*/
|
||||
public void removePolicy(String policyId, String objectId) throws CMISConstraintException, CMISVersioningException,
|
||||
CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException;
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
|
||||
public class CMISStreamNotSupportedException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = -3036139369370574358L;
|
||||
|
||||
public CMISStreamNotSupportedException(CMISTypeDefinition typeDefinition)
|
||||
{
|
||||
super("Stream not supported by type " + typeDefinition.getTypeId(), "streamNotSupported", 403);
|
||||
}
|
||||
|
||||
public CMISStreamNotSupportedException(CMISTypeDefinition typeDefinition, Throwable cause)
|
||||
{
|
||||
super("Stream not supported by type " + typeDefinition.getTypeId(), cause, "streamNotSupported", 403);
|
||||
}
|
||||
}
|
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* The base type definition for CMIS
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public interface CMISTypeDefinition
|
||||
{
|
||||
/**
|
||||
* @return true => type definition is for public consumption
|
||||
*/
|
||||
public boolean isPublic();
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the type
|
||||
*
|
||||
* @return - the type id
|
||||
*/
|
||||
public CMISTypeId getTypeId();
|
||||
|
||||
/**
|
||||
* Get the table name used for queries against the type. This is also a unique identifier for the type. The string
|
||||
* conforms to SQL table naming conventions. TODO: Should we impose a maximum length and if so how do we avoid
|
||||
* collisions from truncations?
|
||||
*
|
||||
* @return the sql table name
|
||||
*/
|
||||
public String getQueryName();
|
||||
|
||||
/**
|
||||
* Get the display name for the type.
|
||||
*
|
||||
* @return - the display name
|
||||
*/
|
||||
public String getDisplayName();
|
||||
|
||||
/**
|
||||
* Get the type for the parent
|
||||
*
|
||||
* @return - the parent type id
|
||||
*/
|
||||
public CMISTypeDefinition getParentType();
|
||||
|
||||
/**
|
||||
* Get the sub-types
|
||||
*
|
||||
* @param descendants
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getSubTypes(boolean descendants);
|
||||
|
||||
/**
|
||||
* Get the base type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition getBaseType();
|
||||
|
||||
/**
|
||||
* Get the description for the type
|
||||
*
|
||||
* @return - the description
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Can objects of this type be created?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isCreatable();
|
||||
|
||||
/**
|
||||
* Are objects of this type fileable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isFileable();
|
||||
|
||||
/**
|
||||
* Is this type queryable? If not, the type may not appear in the FROM clause of a query. This property of the type
|
||||
* is not inherited in the type hierarchy. It is set on each type.
|
||||
*
|
||||
* @return true if queryable
|
||||
*/
|
||||
public boolean isQueryable();
|
||||
|
||||
/**
|
||||
* Is the type full text indexed for querying via CONTAINS()
|
||||
* @return
|
||||
*/
|
||||
public boolean isFullTextIndexed();
|
||||
|
||||
/**
|
||||
* Are objects of this type controllable via Policies.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isControllablePolicy();
|
||||
|
||||
/**
|
||||
* Are objects of this type controllable via ACLs.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isControllableACL();
|
||||
|
||||
/**
|
||||
* Are objects of this type included in super type queries
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isIncludedInSuperTypeQuery();
|
||||
|
||||
/**
|
||||
* Is this type versionable? If true this implies all instances of the type are versionable.
|
||||
*
|
||||
* @return true if versionable
|
||||
*/
|
||||
public boolean isVersionable();
|
||||
|
||||
/**
|
||||
* Is a content stream allowed for this type? It may be disallowed, optional or mandatory.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISContentStreamAllowedEnum getContentStreamAllowed();
|
||||
|
||||
/**
|
||||
* For an association, get the collection of valid source types. For non-associations the collection will be empty.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedSourceTypes();
|
||||
|
||||
/**
|
||||
* For an association, get the collection of valid target types. For non-associations the collection will be empty.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedTargetTypes();
|
||||
|
||||
/**
|
||||
* Gets the property definitions for this type (owned and inherited)
|
||||
*
|
||||
* @return property definitions
|
||||
*/
|
||||
public Map<String, CMISPropertyDefinition> getPropertyDefinitions();
|
||||
|
||||
/**
|
||||
* Gets the property definitions owned by this type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, CMISPropertyDefinition> getOwnedPropertyDefinitions();
|
||||
|
||||
/**
|
||||
* Gets the Action evaluators for this type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> getActionEvaluators();
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* CMIS Type Id
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISTypeId implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -4709046883083948302L;
|
||||
|
||||
private CMISScope scope;
|
||||
private QName typeQName;
|
||||
private String typeId;
|
||||
private QName internalQName;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param scope type scope
|
||||
* @param typeQName name of the CMIS type
|
||||
* @param typeId id of the CMIS type
|
||||
* @param internalQName alfresco class definition representing the type
|
||||
*/
|
||||
public CMISTypeId(CMISScope scope, QName typeQName, String typeId, QName internalQName)
|
||||
{
|
||||
this.scope = scope;
|
||||
this.typeQName = typeQName;
|
||||
this.typeId = typeId;
|
||||
this.internalQName = internalQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CMIS type id string
|
||||
* @return
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return typeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CMIS local name
|
||||
* @return
|
||||
*/
|
||||
public String getLocalName()
|
||||
{
|
||||
return typeQName.getLocalName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CMIS local namespace
|
||||
* @return
|
||||
*/
|
||||
public String getLocalNamespace()
|
||||
{
|
||||
return typeQName.getNamespaceURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scope for the type (Doc, Folder, Relationship or unknown)
|
||||
* @return
|
||||
*/
|
||||
public CMISScope getScope()
|
||||
{
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Alfresco model QName associated with the type
|
||||
*
|
||||
* @return alfresco QName
|
||||
*/
|
||||
public QName getQName()
|
||||
{
|
||||
return internalQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base type id
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeId getBaseTypeId()
|
||||
{
|
||||
switch (scope)
|
||||
{
|
||||
case DOCUMENT:
|
||||
return CMISDictionaryModel.DOCUMENT_TYPE_ID;
|
||||
case FOLDER:
|
||||
return CMISDictionaryModel.FOLDER_TYPE_ID;
|
||||
case RELATIONSHIP:
|
||||
return CMISDictionaryModel.RELATIONSHIP_TYPE_ID;
|
||||
case POLICY:
|
||||
return CMISDictionaryModel.POLICY_TYPE_ID;
|
||||
case OBJECT:
|
||||
return CMISMapping.OBJECT_TYPE_ID;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((typeId == null) ? 0 : typeId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final CMISTypeId other = (CMISTypeId) obj;
|
||||
if (typeQName == null)
|
||||
{
|
||||
if (other.typeQName != null)
|
||||
return false;
|
||||
}
|
||||
else if (!typeQName.equals(other.typeQName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Types Filter Enum
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public enum CMISTypesFilterEnum implements EnumLabel
|
||||
{
|
||||
DOCUMENTS("documents"),
|
||||
FOLDERS("folders"),
|
||||
POLICIES("policies"),
|
||||
ANY("any");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISTypesFilterEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISTypesFilterEnum> FACTORY = new EnumFactory<CMISTypesFilterEnum>(CMISTypesFilterEnum.class, ANY);
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Updatability Enum
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public enum CMISUpdatabilityEnum implements EnumLabel
|
||||
{
|
||||
READ_ONLY("readonly"),
|
||||
READ_AND_WRITE("readwrite"),
|
||||
READ_AND_WRITE_WHEN_CHECKED_OUT("whencheckedout"),
|
||||
ON_CREATE("oncreate");
|
||||
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISUpdatabilityEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISUpdatabilityEnum> FACTORY = new EnumFactory<CMISUpdatabilityEnum>(CMISUpdatabilityEnum.class, null, true);
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
public class CMISVersioningException extends CMISServiceException
|
||||
{
|
||||
private static final long serialVersionUID = 6876828094374256016L;
|
||||
|
||||
public CMISVersioningException(String message)
|
||||
{
|
||||
super(message, "versioning", 409);
|
||||
}
|
||||
|
||||
public CMISVersioningException(Throwable cause)
|
||||
{
|
||||
super(cause, "versioning", 409);
|
||||
}
|
||||
|
||||
public CMISVersioningException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause, "versioning", 409);
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* CMIS Versioning State Enumeration.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public enum CMISVersioningStateEnum implements EnumLabel
|
||||
{
|
||||
NONE("none"), CHECKED_OUT("checkedout"), MAJOR("major"), MINOR("minor");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISVersioningStateEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
public static EnumFactory<CMISVersioningStateEnum> FACTORY = new EnumFactory<CMISVersioningStateEnum>(
|
||||
CMISVersioningStateEnum.class, null, true);
|
||||
}
|
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* http://docs.oasis-open.org/cmis/CMIS/v1.0/os/cmis-spec-v1.0.htm
|
||||
* 2.1.2.1 Property
|
||||
* All properties MUST supply a String queryName attribute which is used for query and filter operations on object-types.
|
||||
* This is an opaque String with limitations. This string SHOULD NOT contain any characters that negatively interact with the BNF grammar.
|
||||
*
|
||||
* The string MUST NOT contain:
|
||||
* whitespace “ “,
|
||||
* comma “,”
|
||||
* double quotes ‘”’
|
||||
* single quotes “’”
|
||||
* backslash “\”
|
||||
* the period “.” character or,
|
||||
* the open “(“ or close “)” parenthesis characters.
|
||||
*
|
||||
*
|
||||
* 2.2.1.2.1 Properties
|
||||
* Description: All of the methods that allow for the retrieval of properties for CMIS Objects have a “Property Filter”
|
||||
* as an optional parameter, which allows the caller to specify a subset of properties for Objects that MUST be returned by the repository in the output of the method.
|
||||
* Optional Input Parameter:
|
||||
* String filter: Value indicating which properties for Objects MUST be returned. Values are:
|
||||
* - Not set: The set of properties to be returned MUST be determined by the repository.
|
||||
* - A comma-delimited list of property definition Query Names: The properties listed MUST be returned.
|
||||
* - “*” : All properties MUST be returned for all objects.
|
||||
* Repositories SHOULD return only the properties specified in the property filter if they exist on the object’s type definition.
|
||||
*
|
||||
* If a property filter specifies a property that is ‘not set’, it MUST be represented as a property element without a value element.
|
||||
|
||||
* @author Dmitry Velichkevich
|
||||
* @author Arseny Kovalchuk
|
||||
*/
|
||||
public class PropertyFilter
|
||||
{
|
||||
public static final String MATCH_ALL_FILTER = "*";
|
||||
public static final String PROPERTY_NAME_TOKENS_DELIMITER = ",";
|
||||
|
||||
private static final char[] PROPERTY_INVALID_CHARS = { ' ', ',', '"', '\'', '\\', '.', ',', '(', ')' };
|
||||
private final List<String> properties;
|
||||
|
||||
/**
|
||||
* @param filter filter value (case insensitive)
|
||||
* @throws CMISFilterNotValidException if filter string isn't valid
|
||||
*/
|
||||
public PropertyFilter(String filter) throws CMISFilterNotValidException
|
||||
{
|
||||
properties = validateFilter(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filter to be validated
|
||||
* @return a list of tokenized and validated properties
|
||||
* @throws CMISFilterNotValidException if one of the filter tokens is not valid
|
||||
*/
|
||||
private static List<String> validateFilter(String filter) throws CMISFilterNotValidException
|
||||
{
|
||||
if (filter != null)
|
||||
{
|
||||
if (!filter.equals(MATCH_ALL_FILTER))
|
||||
{
|
||||
String[] tokens = filter.split(PROPERTY_NAME_TOKENS_DELIMITER);
|
||||
for (int i = 0; i < tokens.length; i++)
|
||||
{
|
||||
String token = tokens[i].trim();
|
||||
if (token.isEmpty() || token.indexOf('*') != -1 || !isValidToken(token))
|
||||
throw new CMISFilterNotValidException("Property filter \"" + filter + "\" is invalid");
|
||||
tokens[i] = token; // trimmed
|
||||
}
|
||||
return Arrays.asList(tokens);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates particular token within property filter
|
||||
*
|
||||
* @param token
|
||||
* @return true if token is valid
|
||||
*/
|
||||
private static boolean isValidToken(String token)
|
||||
{
|
||||
if (token == null)
|
||||
return false;
|
||||
boolean result = true;
|
||||
for (char invalidChar : PROPERTY_INVALID_CHARS)
|
||||
{
|
||||
if (token.indexOf(invalidChar) != -1)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param property property token name
|
||||
* @return <b>true</b> returns if property is allowed by filter. In other case returns <b>false</b>
|
||||
*/
|
||||
public boolean allow(String property)
|
||||
{
|
||||
return properties == null || properties.contains(property);
|
||||
}
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId;
|
||||
import org.alfresco.cmis.CMISAccessControlEntry;
|
||||
import org.alfresco.cmis.CMISConstraintException;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISAccessControlEntriesGroupedByPrincipalIdImpl implements CMISAccessControlEntriesGroupedByPrincipalId
|
||||
{
|
||||
private String principalId;
|
||||
|
||||
private List<String> directPermissions = new ArrayList<String>();
|
||||
|
||||
private List<String> indirectPermissions = new ArrayList<String>();
|
||||
|
||||
/*package */ CMISAccessControlEntriesGroupedByPrincipalIdImpl(String principalId)
|
||||
{
|
||||
this.principalId = principalId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId#getDirectPermissions()
|
||||
*/
|
||||
public List<String> getDirectPermissions()
|
||||
{
|
||||
return directPermissions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId#getInirectPermissions()
|
||||
*/
|
||||
public List<String> getIndirectPermissions()
|
||||
{
|
||||
return indirectPermissions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId#getPrincipalId()
|
||||
*/
|
||||
public String getPrincipalId()
|
||||
{
|
||||
return principalId;
|
||||
}
|
||||
|
||||
/* package */ void addEntry(CMISAccessControlEntry entry) throws CMISConstraintException
|
||||
{
|
||||
if(!principalId.equals(entry.getPrincipalId()))
|
||||
{
|
||||
throw new CMISConstraintException("Grouping error in principal id");
|
||||
}
|
||||
if(entry.getDirect())
|
||||
{
|
||||
directPermissions.add(entry.getPermission());
|
||||
}
|
||||
else
|
||||
{
|
||||
indirectPermissions.add(entry.getPermission());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlEntry;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISAccessControlEntryImpl implements CMISAccessControlEntry
|
||||
{
|
||||
private String principalId;
|
||||
|
||||
private String permission;
|
||||
|
||||
private int position;
|
||||
|
||||
private boolean direct;
|
||||
|
||||
/*package*/ CMISAccessControlEntryImpl(String principalId, String permission, int position, boolean direct)
|
||||
{
|
||||
this.principalId = principalId;
|
||||
this.permission = permission;
|
||||
this.position = position;
|
||||
this.direct = direct;
|
||||
}
|
||||
|
||||
/*package*/ CMISAccessControlEntryImpl(String principalId, String permission, int position)
|
||||
{
|
||||
this(principalId, permission, position, position == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used for external calls to add or delete aces.
|
||||
* (All must be at position 0 === directly set on the object)
|
||||
*
|
||||
* @param principalId
|
||||
* @param permission
|
||||
*/
|
||||
public CMISAccessControlEntryImpl(String principalId, String permission)
|
||||
{
|
||||
this(principalId, permission, 0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlEntry#getDirect()
|
||||
*/
|
||||
public boolean getDirect()
|
||||
{
|
||||
return direct;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlEntry#getPermission()
|
||||
*/
|
||||
public String getPermission()
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlEntry#getPrincipalId()
|
||||
*/
|
||||
public String getPrincipalId()
|
||||
{
|
||||
return principalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the position
|
||||
*/
|
||||
public int getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (direct ? 1231 : 1237);
|
||||
result = prime * result + ((permission == null) ? 0 : permission.hashCode());
|
||||
result = prime * result + position;
|
||||
result = prime * result + ((principalId == null) ? 0 : principalId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CMISAccessControlEntryImpl other = (CMISAccessControlEntryImpl) obj;
|
||||
if (direct != other.direct)
|
||||
return false;
|
||||
if (permission == null)
|
||||
{
|
||||
if (other.permission != null)
|
||||
return false;
|
||||
}
|
||||
else if (!permission.equals(other.permission))
|
||||
return false;
|
||||
if (position != other.position)
|
||||
return false;
|
||||
if (principalId == null)
|
||||
{
|
||||
if (other.principalId != null)
|
||||
return false;
|
||||
}
|
||||
else if (!principalId.equals(other.principalId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[");
|
||||
builder.append(getPrincipalId()).append(", ");
|
||||
builder.append(getPermission()).append(", ");
|
||||
builder.append(getPosition()).append(", ");
|
||||
builder.append(getDirect()).append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId;
|
||||
import org.alfresco.cmis.CMISAccessControlEntry;
|
||||
import org.alfresco.cmis.CMISAccessControlReport;
|
||||
import org.alfresco.cmis.CMISConstraintException;
|
||||
|
||||
/**
|
||||
* A simple CMIS access control report
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISAccessControlReportImpl implements CMISAccessControlReport
|
||||
{
|
||||
private ArrayList<CMISAccessControlEntry> entries = new ArrayList<CMISAccessControlEntry>();
|
||||
|
||||
private boolean extract = false;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlReport#getAccessControlEntries()
|
||||
*/
|
||||
public List<CMISAccessControlEntry> getAccessControlEntries()
|
||||
{
|
||||
return entries;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlReport#isExtract()
|
||||
*/
|
||||
public boolean isExact()
|
||||
{
|
||||
return extract;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set extract.
|
||||
* @param extract
|
||||
*/
|
||||
public void setExtract(boolean extract)
|
||||
{
|
||||
this.extract = extract;
|
||||
}
|
||||
|
||||
/*package*/ void addEntry(CMISAccessControlEntry entry)
|
||||
{
|
||||
removeEntry(entry);
|
||||
entries.add(entry);
|
||||
}
|
||||
|
||||
/*package*/ void removeEntry(CMISAccessControlEntry entry)
|
||||
{
|
||||
for(int i = 0; i < entries.size(); i++)
|
||||
{
|
||||
CMISAccessControlEntry current = entries.get(i);
|
||||
if(current.getPrincipalId().equals(entry.getPrincipalId()) && current.getPermission().equals(entry.getPermission()))
|
||||
{
|
||||
entries.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlReport#getAccessControlEntriesGroupedByPrincipalId()
|
||||
*/
|
||||
public List<? extends CMISAccessControlEntriesGroupedByPrincipalId> getAccessControlEntriesGroupedByPrincipalId() throws CMISConstraintException
|
||||
{
|
||||
HashMap<String, CMISAccessControlEntriesGroupedByPrincipalIdImpl> grouped = new HashMap<String, CMISAccessControlEntriesGroupedByPrincipalIdImpl>();
|
||||
for(CMISAccessControlEntry entry : getAccessControlEntries())
|
||||
{
|
||||
CMISAccessControlEntriesGroupedByPrincipalIdImpl value = grouped.get(entry.getPrincipalId());
|
||||
if(value == null)
|
||||
{
|
||||
value = new CMISAccessControlEntriesGroupedByPrincipalIdImpl(entry.getPrincipalId());
|
||||
grouped.put(entry.getPrincipalId(), value);
|
||||
}
|
||||
value.addEntry(entry);
|
||||
}
|
||||
ArrayList<CMISAccessControlEntriesGroupedByPrincipalIdImpl> answer = new ArrayList<CMISAccessControlEntriesGroupedByPrincipalIdImpl>(grouped.values());
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,507 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlEntry;
|
||||
import org.alfresco.cmis.CMISAccessControlReport;
|
||||
import org.alfresco.cmis.CMISAccessControlService;
|
||||
import org.alfresco.cmis.CMISAclCapabilityEnum;
|
||||
import org.alfresco.cmis.CMISAclPropagationEnum;
|
||||
import org.alfresco.cmis.CMISAclSupportedPermissionEnum;
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.cmis.CMISConstraintException;
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISPermissionDefinition;
|
||||
import org.alfresco.cmis.CMISPermissionMapping;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.opencmis.CMISAccessControlFormatEnum;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.permissions.PermissionReference;
|
||||
import org.alfresco.repo.security.permissions.impl.AccessPermissionImpl;
|
||||
import org.alfresco.repo.security.permissions.impl.ModelDAO;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*/
|
||||
public class CMISAccessControlServiceImpl implements CMISAccessControlService
|
||||
{
|
||||
private CMISAclCapabilityEnum aclCapabilityEnum;
|
||||
|
||||
private CMISAclSupportedPermissionEnum aclSupportedPermissionEnum;
|
||||
|
||||
private CMISAclPropagationEnum aclPropagationEnum;
|
||||
|
||||
private ModelDAO permissionModelDao;
|
||||
|
||||
private PermissionService permissionService;
|
||||
|
||||
private CMISMapping cmisMapping;
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private CMISDictionaryService cmisDictionaryService;
|
||||
|
||||
/**
|
||||
* @param aclCapabilityEnum
|
||||
* the aclCapabilityEnum to set
|
||||
*/
|
||||
public void setAclCapabilityEnum(CMISAclCapabilityEnum aclCapabilityEnum)
|
||||
{
|
||||
this.aclCapabilityEnum = aclCapabilityEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the acl supported permission enum.
|
||||
*
|
||||
* @param aclSupportedPermissionEnum
|
||||
* the aclSupportedPermissionEnum to set
|
||||
*/
|
||||
public void setAclSupportedPermissionEnum(CMISAclSupportedPermissionEnum aclSupportedPermissionEnum)
|
||||
{
|
||||
this.aclSupportedPermissionEnum = aclSupportedPermissionEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aclPropagationEnum
|
||||
* the aclPropagationEnum to set
|
||||
*/
|
||||
public void setAclPropagationEnum(CMISAclPropagationEnum aclPropagationEnum)
|
||||
{
|
||||
this.aclPropagationEnum = aclPropagationEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionModelDao
|
||||
* the permissionModelDao to set
|
||||
*/
|
||||
public void setPermissionModelDao(ModelDAO permissionModelDao)
|
||||
{
|
||||
this.permissionModelDao = permissionModelDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService
|
||||
* the permissionService to set
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cmis mapping.
|
||||
*
|
||||
* @param cmisMapping
|
||||
* the cmis mapping
|
||||
*/
|
||||
public void setCMISMapping(CMISMapping cmisMapping)
|
||||
{
|
||||
this.cmisMapping = cmisMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService
|
||||
* the nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmisDictionaryService
|
||||
* the cmisDictionaryService to set
|
||||
*/
|
||||
public void setCMISDictionaryService(CMISDictionaryService cmisDictionaryService)
|
||||
{
|
||||
this.cmisDictionaryService = cmisDictionaryService;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#applyAcl(org.alfresco.service.cmr.repository.NodeRef,
|
||||
* java.util.List)
|
||||
*/
|
||||
public CMISAccessControlReport applyAcl(NodeRef nodeRef, List<CMISAccessControlEntry> acesToApply) throws CMISConstraintException
|
||||
{
|
||||
Set<CMISAccessControlEntry> acesToAdd = new LinkedHashSet<CMISAccessControlEntry>(acesToApply);
|
||||
List<? extends CMISAccessControlEntry> acesExisting = getAcl(nodeRef,
|
||||
CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS).getAccessControlEntries();
|
||||
List<CMISAccessControlEntry> acesToRemove = new ArrayList<CMISAccessControlEntry>(acesExisting.size());
|
||||
for (CMISAccessControlEntry accessControlEntry : acesExisting)
|
||||
{
|
||||
// Only pay attention to existing direct entries
|
||||
if (accessControlEntry.getDirect() && !acesToAdd.remove(accessControlEntry))
|
||||
{
|
||||
acesToRemove.add(accessControlEntry);
|
||||
}
|
||||
}
|
||||
return applyAcl(nodeRef, acesToRemove, new ArrayList<CMISAccessControlEntry>(acesToAdd),
|
||||
CMISAclPropagationEnum.PROPAGATE,
|
||||
CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#applyAcl(org.alfresco.service.cmr.repository.NodeRef,
|
||||
* java.util.List, java.util.List, org.alfresco.cmis.CMISAclPropagationEnum)
|
||||
*/
|
||||
public CMISAccessControlReport applyAcl(NodeRef nodeRef, List<CMISAccessControlEntry> acesToRemove, List<CMISAccessControlEntry> acesToAdd, CMISAclPropagationEnum propagation,
|
||||
CMISAccessControlFormatEnum format) throws CMISConstraintException
|
||||
{
|
||||
if (propagation == CMISAclPropagationEnum.OBJECT_ONLY)
|
||||
{
|
||||
throw new CMISConstraintException("Unsupported ACL propagation mode: " + propagation);
|
||||
}
|
||||
// Check controllable ACL
|
||||
QName type = nodeService.getType(nodeRef);
|
||||
CMISTypeDefinition cmisType = cmisDictionaryService.findTypeForClass(type);
|
||||
if (false == cmisType.isControllableACL())
|
||||
{
|
||||
throw new CMISConstraintException("ACLs are not supported for type: " + cmisType.getDisplayName());
|
||||
}
|
||||
// TODO: Check valid permissions. We do not check this internally. Ignore for now ...
|
||||
|
||||
if (acesToRemove != null)
|
||||
{
|
||||
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(nodeRef);
|
||||
for (CMISAccessControlEntry entry : acesToRemove)
|
||||
{
|
||||
String alfrescoPermission = cmisMapping.getSetPermission(compressPermission(entry.getPermission()));
|
||||
AccessPermission toCheck = new AccessPermissionImpl(alfrescoPermission, AccessStatus.ALLOWED, entry.getPrincipalId(), 0);
|
||||
if (false == permissions.contains(toCheck))
|
||||
{
|
||||
throw new CMISConstraintException("No matching ACE found to delete");
|
||||
}
|
||||
permissionService.deletePermission(nodeRef, entry.getPrincipalId(), alfrescoPermission);
|
||||
}
|
||||
}
|
||||
if (acesToAdd != null)
|
||||
{
|
||||
for (CMISAccessControlEntry entry : acesToAdd)
|
||||
{
|
||||
String alfrescoPermission = cmisMapping.getSetPermission(compressPermission(entry.getPermission()));
|
||||
permissionService.setPermission(nodeRef, entry.getPrincipalId(), alfrescoPermission, true);
|
||||
}
|
||||
}
|
||||
return getAcl(nodeRef, format);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getAcl(org.alfresco.service.cmr.repository.NodeRef,
|
||||
* org.alfresco.cmis.CMISAccessControlFormatEnum)
|
||||
*/
|
||||
public CMISAccessControlReport getAcl(NodeRef nodeRef, CMISAccessControlFormatEnum format)
|
||||
{
|
||||
CMISAccessControlReportImpl merge = new CMISAccessControlReportImpl();
|
||||
// Need to compact deny to mask correctly
|
||||
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(nodeRef);
|
||||
ArrayList<AccessPermission> ordered = new ArrayList<AccessPermission>();
|
||||
AccessPermissionComparator comparator = new AccessPermissionComparator();
|
||||
for (AccessPermission current : permissions)
|
||||
{
|
||||
int index = Collections.binarySearch(ordered, current, comparator);
|
||||
if (index < 0)
|
||||
{
|
||||
ordered.add(-index - 1, current);
|
||||
}
|
||||
}
|
||||
|
||||
for (AccessPermission entry : ordered)
|
||||
{
|
||||
if (entry.getAccessStatus() == AccessStatus.ALLOWED)
|
||||
{
|
||||
//answer.addEntry(new CMISAccessControlEntryImpl(entry.getAuthority(), expandPermission(cmisMapping.getReportedPermission(getPermission(entry.getPermission()),
|
||||
// format)), entry.getPosition()));
|
||||
merge.addEntry(new CMISAccessControlEntryImpl(entry.getAuthority(), entry.getPermission(), entry.getPosition()));
|
||||
}
|
||||
else if (entry.getAccessStatus() == AccessStatus.DENIED)
|
||||
{
|
||||
//answer.removeEntry(new CMISAccessControlEntryImpl(entry.getAuthority(), expandPermission(cmisMapping.getReportedPermission(getPermission(entry.getPermission()),
|
||||
// format)), entry.getPosition()));
|
||||
merge.removeEntry(new CMISAccessControlEntryImpl(entry.getAuthority(), entry.getPermission(), entry.getPosition()));
|
||||
}
|
||||
}
|
||||
|
||||
CMISAccessControlReportImpl answer = new CMISAccessControlReportImpl();
|
||||
for(CMISAccessControlEntry entry : merge.getAccessControlEntries())
|
||||
{
|
||||
CMISAccessControlEntryImpl impl = (CMISAccessControlEntryImpl)entry;
|
||||
PermissionReference permissionReference = permissionModelDao.getPermissionReference(null, impl.getPermission());
|
||||
Set<PermissionReference> longForms = permissionModelDao.getGranteePermissions(permissionReference);
|
||||
HashSet<String> shortForms = new HashSet<String>();
|
||||
for(PermissionReference longForm : longForms)
|
||||
{
|
||||
shortForms.add(getPermission(longForm));
|
||||
}
|
||||
for(Pair<String, Boolean> toAdd : cmisMapping.getReportedPermissions(impl.getPermission(), shortForms, permissionModelDao.hasFull(permissionReference), impl.getDirect(), format))
|
||||
{
|
||||
answer.addEntry(new CMISAccessControlEntryImpl(impl.getPrincipalId(), expandPermission(toAdd.getFirst()), impl.getPosition(), toAdd.getSecond()));
|
||||
}
|
||||
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
private String getPermission(PermissionReference permissionReference)
|
||||
{
|
||||
if (permissionModelDao.isUnique(permissionReference))
|
||||
{
|
||||
return permissionReference.getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return permissionReference.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private String expandPermission(String permission)
|
||||
{
|
||||
if (permission.equals(CMIS_ALL_PERMISSION))
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
else if (permission.equals(CMIS_READ_PERMISSION))
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
else if (permission.equals(CMIS_WRITE_PERMISSION))
|
||||
{
|
||||
return permission;
|
||||
|
||||
}
|
||||
else if (permission.startsWith("{"))
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
else
|
||||
{
|
||||
PermissionReference permissionReference = permissionModelDao.getPermissionReference(null, permission);
|
||||
return permissionReference.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private String compressPermission(String permission) {
|
||||
int sepIndex;
|
||||
if (permission.equals(CMIS_ALL_PERMISSION) || permission.equals(CMIS_READ_PERMISSION)
|
||||
|| permission.equals(CMIS_WRITE_PERMISSION) || !permission.startsWith("{")
|
||||
|| (sepIndex = permission.lastIndexOf('.')) == -1) {
|
||||
return permission;
|
||||
}
|
||||
return permission.substring(sepIndex + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getAclCapability()
|
||||
*/
|
||||
public CMISAclCapabilityEnum getAclCapability()
|
||||
{
|
||||
return aclCapabilityEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the acl capability enum.
|
||||
*
|
||||
* @param aclCapabilityEnum
|
||||
*/
|
||||
public void setAclCapability(CMISAclCapabilityEnum aclCapabilityEnum)
|
||||
{
|
||||
this.aclCapabilityEnum = aclCapabilityEnum;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getSupportedPermissions()
|
||||
*/
|
||||
public CMISAclSupportedPermissionEnum getSupportedPermissions()
|
||||
{
|
||||
return this.aclSupportedPermissionEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the supported permissions.
|
||||
*
|
||||
* @param aclSupportedPermissionEnum
|
||||
* the supported permissions
|
||||
*/
|
||||
public void setSupportedPermissions(CMISAclSupportedPermissionEnum aclSupportedPermissionEnum)
|
||||
{
|
||||
this.aclSupportedPermissionEnum = aclSupportedPermissionEnum;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getAclPropagation()
|
||||
*/
|
||||
public CMISAclPropagationEnum getAclPropagation()
|
||||
{
|
||||
return aclPropagationEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the acl propagation enum.
|
||||
*
|
||||
* @param aclPropagationEnum
|
||||
*/
|
||||
public void setAclPropagation(CMISAclPropagationEnum aclPropagationEnum)
|
||||
{
|
||||
this.aclPropagationEnum = aclPropagationEnum;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getPermissionMappings()
|
||||
*/
|
||||
public List<? extends CMISPermissionMapping> getPermissionMappings()
|
||||
{
|
||||
ArrayList<CMISPermissionMappingImpl> mappings = new ArrayList<CMISPermissionMappingImpl>();
|
||||
for(CMISAllowedActionEnum e : EnumSet.allOf(CMISAllowedActionEnum.class))
|
||||
{
|
||||
Map<String, List<String>> enumMappings = e.getPermissionMapping();
|
||||
for(String key : enumMappings.keySet())
|
||||
{
|
||||
List<String> list = enumMappings.get(key);
|
||||
CMISPermissionMappingImpl mapping = new CMISPermissionMappingImpl(key, list);
|
||||
mappings.add(mapping);
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getRepositoryPermissions()
|
||||
*/
|
||||
public List<CMISPermissionDefinition> getRepositoryPermissions()
|
||||
{
|
||||
ArrayList<CMISPermissionDefinition> answer = new ArrayList<CMISPermissionDefinition>();
|
||||
PermissionReference allPermission = permissionModelDao.getPermissionReference(null, PermissionService.ALL_PERMISSIONS);
|
||||
Set<PermissionReference> all = permissionModelDao.getAllExposedPermissions();
|
||||
for (PermissionReference pr : all)
|
||||
{
|
||||
addPermissionDefinition(answer, pr);
|
||||
}
|
||||
// Add All
|
||||
addPermissionDefinition(answer, allPermission);
|
||||
// Add CMIS permissions
|
||||
answer.add(new CMISPermissionDefinitionImpl(CMIS_ALL_PERMISSION));
|
||||
answer.add(new CMISPermissionDefinitionImpl(CMIS_READ_PERMISSION));
|
||||
answer.add(new CMISPermissionDefinitionImpl(CMIS_WRITE_PERMISSION));
|
||||
return answer;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getPrincipalAnonymous()
|
||||
*/
|
||||
public String getPrincipalAnonymous()
|
||||
{
|
||||
return AuthenticationUtil.getGuestUserName();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISAccessControlService#getPrincipalAnyone()
|
||||
*/
|
||||
public String getPrincipalAnyone()
|
||||
{
|
||||
return PermissionService.ALL_AUTHORITIES;
|
||||
}
|
||||
|
||||
private void addPermissionDefinition(ArrayList<CMISPermissionDefinition> list, PermissionReference pr)
|
||||
{
|
||||
CMISPermissionDefinitionImpl def = new CMISPermissionDefinitionImpl(getPermissionString(pr));
|
||||
list.add(def);
|
||||
}
|
||||
|
||||
private String getPermissionString(PermissionReference pr)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(pr.getQName().toString());
|
||||
builder.append(".");
|
||||
builder.append(pr.getName());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static class AccessPermissionComparator implements Comparator<AccessPermission>
|
||||
{
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare(AccessPermission left, AccessPermission right)
|
||||
{
|
||||
if (left.getPosition() != right.getPosition())
|
||||
{
|
||||
return right.getPosition() - left.getPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (left.getAccessStatus() != right.getAccessStatus())
|
||||
{
|
||||
return (left.getAccessStatus() == AccessStatus.DENIED) ? -1 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int compare = left.getAuthority().compareTo(right.getAuthority());
|
||||
if (compare != 0)
|
||||
{
|
||||
return compare;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (left.getPermission().compareTo(right.getPermission()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import org.alfresco.opencmis.EnumFactory;
|
||||
import org.alfresco.opencmis.EnumLabel;
|
||||
|
||||
/**
|
||||
* Part two of the allowable action key for the permission mappings
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public enum CMISAllowedActionKeyTypeEnum implements EnumLabel
|
||||
{
|
||||
/**
|
||||
* Folder
|
||||
*/
|
||||
FOLDER("Folder"),
|
||||
/**
|
||||
* Object
|
||||
*/
|
||||
OBJECT("Object"),
|
||||
/**
|
||||
* Source
|
||||
*/
|
||||
SOURCE("Source"),
|
||||
/**
|
||||
* Target
|
||||
*/
|
||||
TARGET("Target"),
|
||||
/**
|
||||
* Document
|
||||
*/
|
||||
DOCUMENT("Document"),
|
||||
/**
|
||||
* Policy
|
||||
*/
|
||||
POLICY("Policy");
|
||||
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param label
|
||||
*/
|
||||
CMISAllowedActionKeyTypeEnum(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.EnumLabel#label()
|
||||
*/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory for CMISAclCapabilityEnum
|
||||
*/
|
||||
public static EnumFactory<CMISAllowedActionKeyTypeEnum> FACTORY = new EnumFactory<CMISAllowedActionKeyTypeEnum>(CMISAllowedActionKeyTypeEnum.class, null, true);
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import org.alfresco.cmis.CMISPermissionDefinition;
|
||||
|
||||
/**
|
||||
* Implementation class for a simple CMIS permission definition.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISPermissionDefinitionImpl implements CMISPermissionDefinition
|
||||
{
|
||||
private String permission;
|
||||
|
||||
private String description;
|
||||
|
||||
/*package*/ CMISPermissionDefinitionImpl(String permission)
|
||||
{
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
/*package*/ CMISPermissionDefinitionImpl(String permission, String description)
|
||||
{
|
||||
this(permission);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISPermissionDefinition#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
if(description != null)
|
||||
{
|
||||
return description;
|
||||
}
|
||||
else
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISPermissionDefinition#getPermission()
|
||||
*/
|
||||
public String getPermission()
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((permission == null) ? 0 : permission.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final CMISPermissionDefinitionImpl other = (CMISPermissionDefinitionImpl) obj;
|
||||
if (permission == null)
|
||||
{
|
||||
if (other.permission != null)
|
||||
return false;
|
||||
}
|
||||
else if (!permission.equals(other.permission))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISPermissionMapping;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public class CMISPermissionMappingImpl implements CMISPermissionMapping
|
||||
{
|
||||
String key;
|
||||
|
||||
List<String> permissions;
|
||||
|
||||
CMISPermissionMappingImpl(String key, List<String> permissions)
|
||||
{
|
||||
this.key = key;
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISPermissionMapping#getKey()
|
||||
*/
|
||||
public String getKey()
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISPermissionMapping#getPermissions()
|
||||
*/
|
||||
public List<String> getPermissions()
|
||||
{
|
||||
return permissions;
|
||||
}
|
||||
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.acl;
|
||||
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public interface CMISPermissionMappingKey
|
||||
{
|
||||
/**
|
||||
* Get the allowed action enum.
|
||||
* @return the allowed action enum.
|
||||
*/
|
||||
public CMISAllowedActionEnum getAllowedActionEnum();
|
||||
|
||||
/**
|
||||
* Get the allowed action key type enum.
|
||||
* @return the allowed action key type enum.
|
||||
*/
|
||||
public CMISAllowedActionKeyTypeEnum getAllowedActionKeyTypeEnum();
|
||||
}
|
@@ -1,122 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.changelog;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.alfresco.cmis.CMISChangeEvent;
|
||||
import org.alfresco.cmis.CMISChangeType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* CMISChangeEvent Implementation
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class CMISChangeEventImpl implements CMISChangeEvent
|
||||
{
|
||||
private CMISChangeType changeType;
|
||||
private Date changeTime;
|
||||
private NodeRef changedNode;
|
||||
private String objectId;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new CMIS change event.
|
||||
*
|
||||
* @param changeType
|
||||
* the change type
|
||||
* @param changeTime
|
||||
* the change time
|
||||
* @param changedNode
|
||||
* the changed node
|
||||
* @param objectId
|
||||
* the object id
|
||||
*/
|
||||
public CMISChangeEventImpl(CMISChangeType changeType, Date changeTime, NodeRef changedNode, String objectId)
|
||||
{
|
||||
this.changeType = changeType;
|
||||
this.changeTime = changeTime;
|
||||
this.changedNode = changedNode;
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeEvent#getChangeType()
|
||||
*/
|
||||
public CMISChangeType getChangeType()
|
||||
{
|
||||
return changeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeEvent#getChangeTime()
|
||||
*/
|
||||
public Date getChangeTime()
|
||||
{
|
||||
return changeTime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeEvent#getChangedNode()
|
||||
*/
|
||||
public NodeRef getChangedNode()
|
||||
{
|
||||
return changedNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeEvent#getObjectId()
|
||||
*/
|
||||
public String getObjectId()
|
||||
{
|
||||
return objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof CMISChangeEvent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CMISChangeEvent converted = (CMISChangeEvent) obj;
|
||||
return same(changedNode, converted.getChangedNode()) && same(changeType, converted.getChangeType()) && same(changeTime, converted.getChangeTime());
|
||||
}
|
||||
|
||||
private boolean same(Object left, Object right)
|
||||
{
|
||||
return (null == left) ? (null == right) : (left.equals(right));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = (null != changedNode) ? (changedNode.hashCode()) : (31);
|
||||
return result * 37 + (null != changeType ? changeType.hashCode() : 31) + (null != changeTime ? changeTime.hashCode() : 31);
|
||||
}
|
||||
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.changelog;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISChangeEvent;
|
||||
import org.alfresco.cmis.CMISChangeLog;
|
||||
|
||||
/**
|
||||
* CMISChangeLog Implementation
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class CMISChangeLogImpl implements CMISChangeLog
|
||||
{
|
||||
private boolean hasMoreItems;
|
||||
private List<CMISChangeEvent> changeEvents = new LinkedList<CMISChangeEvent>();
|
||||
private String nextChangeToken;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLog#getChangeEvents()
|
||||
*/
|
||||
public List<CMISChangeEvent> getChangeEvents()
|
||||
{
|
||||
return changeEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the change events
|
||||
*
|
||||
* @param changeEvents list of change events
|
||||
*/
|
||||
protected void setChangeEvents(List<CMISChangeEvent> changeEvents)
|
||||
{
|
||||
this.changeEvents = changeEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLog#getEventCount()
|
||||
*/
|
||||
public Integer getEventCount()
|
||||
{
|
||||
return changeEvents.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLog#getNextChangeToken()
|
||||
*/
|
||||
public String getNextChangeToken()
|
||||
{
|
||||
return nextChangeToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the next ChangeToken
|
||||
*
|
||||
* @param nextChangeToken the next ChangeToken
|
||||
*/
|
||||
public void setNextChangeToken(String nextChangeToken)
|
||||
{
|
||||
this.nextChangeToken = nextChangeToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLog#hasMoreItems()
|
||||
*/
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return hasMoreItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the hasMoreItems value
|
||||
*
|
||||
* @param hasMoreItems hasMoreItems value
|
||||
*/
|
||||
protected void setHasMoreItems(boolean hasMoreItems)
|
||||
{
|
||||
this.hasMoreItems = hasMoreItems;
|
||||
}
|
||||
|
||||
}
|
@@ -1,346 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.changelog;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.cmis.CMISBaseObjectTypeIds;
|
||||
import org.alfresco.cmis.CMISCapabilityChanges;
|
||||
import org.alfresco.cmis.CMISChangeEvent;
|
||||
import org.alfresco.cmis.CMISChangeLog;
|
||||
import org.alfresco.cmis.CMISChangeLogService;
|
||||
import org.alfresco.cmis.CMISChangeType;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.opencmis.CMISChangeLogDataExtractor;
|
||||
import org.alfresco.service.cmr.audit.AuditQueryParameters;
|
||||
import org.alfresco.service.cmr.audit.AuditService;
|
||||
import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* ChangeLog Service Implementation
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class CMISChangeLogServiceImpl implements CMISChangeLogService
|
||||
{
|
||||
private static final String PATH_DELIMITER = "/";
|
||||
private static final int DEFAULT_RETURN_SIZE = 100;
|
||||
|
||||
private AuditService auditService;
|
||||
private String cmisAuditApplicationName;
|
||||
private List<CMISBaseObjectTypeIds> changesOnTypeCapability;
|
||||
|
||||
/**
|
||||
* Set the AuditService.
|
||||
*
|
||||
* @param auditService AuditService
|
||||
*/
|
||||
public void setAuditService(AuditService auditService)
|
||||
{
|
||||
this.auditService = auditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Audit Application Name.
|
||||
*
|
||||
* @param cmisAuditApplicationName Audit Application Name
|
||||
*/
|
||||
public void setCmisAuditApplicationName(String cmisAuditApplicationName)
|
||||
{
|
||||
this.cmisAuditApplicationName = cmisAuditApplicationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ChangesOnTypeCapability.
|
||||
*
|
||||
* @param changesOnTypeCapability list of CMISBaseObjectTypeIds
|
||||
*/
|
||||
public void setChangesOnTypeCapability(List<CMISBaseObjectTypeIds> changesOnTypeCapability)
|
||||
{
|
||||
this.changesOnTypeCapability = changesOnTypeCapability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getCapability()
|
||||
*/
|
||||
public CMISCapabilityChanges getCapability()
|
||||
{
|
||||
return (auditService.isAuditEnabled(cmisAuditApplicationName, PATH_DELIMITER + cmisAuditApplicationName)) ? (CMISCapabilityChanges.OBJECTIDSONLY)
|
||||
: (CMISCapabilityChanges.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws CMISInvalidArgumentException
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getChangeLogEvents(java.lang.String, java.lang.Integer)
|
||||
*/
|
||||
public CMISChangeLog getChangeLogEvents(String changeLogToken, Integer maxItems) throws CMISInvalidArgumentException
|
||||
{
|
||||
if (!auditService.isAuditEnabled(cmisAuditApplicationName, ("/" + cmisAuditApplicationName)))
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Auditing for " + cmisAuditApplicationName + " is disabled!");
|
||||
}
|
||||
CMISChangeLogImpl result = new CMISChangeLogImpl();
|
||||
final List<CMISChangeEvent> changeEvents = result.getChangeEvents();
|
||||
EntryIdCallback changeLogCollectingCallback = new EntryIdCallback(true)
|
||||
{
|
||||
@Override
|
||||
public boolean handleAuditEntry(Long entryId, String user, long time, Map<String, Serializable> values)
|
||||
{
|
||||
List<CMISChangeEvent> changeLogEvents = convertValuesMapToChangeLogEvents(values, time);
|
||||
changeEvents.addAll(changeLogEvents);
|
||||
return super.handleAuditEntry(entryId, user, time, values);
|
||||
}
|
||||
};
|
||||
Long from;
|
||||
try
|
||||
{
|
||||
from = changeLogToken != null ? Long.parseLong(changeLogToken) : null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new CMISInvalidArgumentException("Invalid change log token " + changeLogToken);
|
||||
}
|
||||
AuditQueryParameters params = new AuditQueryParameters();
|
||||
params.setApplicationName(cmisAuditApplicationName);
|
||||
params.setForward(true);
|
||||
params.setFromId(from);
|
||||
|
||||
// Query one past the last item, so that we know what the next ID is
|
||||
int maxAmount = ((null == maxItems) || (0 == maxItems)) ? (0) : (maxItems + 1);
|
||||
auditService.auditQuery(changeLogCollectingCallback, params, maxAmount);
|
||||
|
||||
if ((0 != maxAmount) && (changeEvents.size() > maxItems))
|
||||
{
|
||||
changeEvents.remove(changeEvents.size() - 1);
|
||||
result.setNextChangeToken(changeLogCollectingCallback.getEntryId().toString());
|
||||
result.setHasMoreItems(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getChangesIncomplete()
|
||||
*/
|
||||
public boolean getChangesIncomplete()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getLastChangeLogToken()
|
||||
*/
|
||||
public String getLastChangeLogToken()
|
||||
{
|
||||
EntryIdCallback auditQueryCallback = new EntryIdCallback(false);
|
||||
AuditQueryParameters params = new AuditQueryParameters();
|
||||
params.setApplicationName(cmisAuditApplicationName);
|
||||
params.setForward(false);
|
||||
auditService.auditQuery(auditQueryCallback, params, 1);
|
||||
return auditQueryCallback.getEntryId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getPreviousPageChangeLogToken(java.lang.String, java.lang.Integer)
|
||||
*/
|
||||
public String getPreviousPageChangeLogToken(String currentPageToken, Integer maxItems)
|
||||
{
|
||||
if (currentPageToken == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
maxItems = maxItems == null ? DEFAULT_RETURN_SIZE : maxItems;
|
||||
EntryIdCallback auditQueryCallback = new EntryIdCallback(false);
|
||||
AuditQueryParameters params = new AuditQueryParameters();
|
||||
params.setApplicationName(cmisAuditApplicationName);
|
||||
params.setForward(false);
|
||||
params.setToId(Long.parseLong(currentPageToken));
|
||||
auditService.auditQuery(auditQueryCallback, params, maxItems);
|
||||
return auditQueryCallback.getEntryId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getLastPageChangeLogToken(java.lang.String, java.lang.Integer)
|
||||
*/
|
||||
public String getLastPageChangeLogToken(String currentPageToken, Integer maxItems)
|
||||
{
|
||||
maxItems = maxItems == null ? DEFAULT_RETURN_SIZE : maxItems;
|
||||
EntryIdCallback auditQueryCallback = new PageStartEntryIdCallback(maxItems);
|
||||
AuditQueryParameters params = new AuditQueryParameters();
|
||||
params.setApplicationName(cmisAuditApplicationName);
|
||||
if (currentPageToken != null)
|
||||
{
|
||||
params.setFromId(Long.parseLong(currentPageToken));
|
||||
}
|
||||
auditService.auditQuery(auditQueryCallback, params, -1);
|
||||
return auditQueryCallback.getEntryId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.cmis.CMISChangeLogService#getChangesOnTypeCapability()
|
||||
*/
|
||||
public List<CMISBaseObjectTypeIds> getChangesOnTypeCapability()
|
||||
{
|
||||
if (null == changesOnTypeCapability)
|
||||
{
|
||||
changesOnTypeCapability = new LinkedList<CMISBaseObjectTypeIds>();
|
||||
}
|
||||
return changesOnTypeCapability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts audit values map to list of CMISChangeEvents.
|
||||
*
|
||||
* @param values audit values map
|
||||
* @param time audit event time
|
||||
* @return list of CMISChangeEvent
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<CMISChangeEvent> convertValuesMapToChangeLogEvents(Map<String, Serializable> values, long time)
|
||||
{
|
||||
List<CMISChangeEvent> result = new ArrayList<CMISChangeEvent>();
|
||||
if (values != null && values.size() > 0)
|
||||
{
|
||||
for (Entry<String, Serializable> entry : values.entrySet())
|
||||
{
|
||||
if (entry.getKey() != null && entry.getValue() != null)
|
||||
{
|
||||
String path = entry.getKey();
|
||||
CMISChangeType changeType = getCMISChangeType(path);
|
||||
if (changeType != null && entry.getValue() instanceof Map)
|
||||
{
|
||||
Map<String, Serializable> valueMap = (Map<String, Serializable>)entry.getValue();
|
||||
result.add(new CMISChangeEventImpl(changeType, new Date(time), (NodeRef) valueMap
|
||||
.get(CMISChangeLogDataExtractor.KEY_NODE_REF), (String) valueMap
|
||||
.get(CMISChangeLogDataExtractor.KEY_OBJECT_ID)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets CMISChangeType by audit path.
|
||||
*
|
||||
* @param auditPath audit path
|
||||
* @return CMISChangeType
|
||||
*/
|
||||
private CMISChangeType getCMISChangeType(String auditPath)
|
||||
{
|
||||
CMISChangeType result = null;
|
||||
if (auditPath != null)
|
||||
{
|
||||
if (auditPath.startsWith(PATH_DELIMITER))
|
||||
{
|
||||
auditPath = auditPath.substring(PATH_DELIMITER.length());
|
||||
}
|
||||
if (auditPath.startsWith(cmisAuditApplicationName))
|
||||
{
|
||||
auditPath = auditPath.substring(cmisAuditApplicationName.length());
|
||||
}
|
||||
if (auditPath.startsWith(PATH_DELIMITER))
|
||||
{
|
||||
auditPath = auditPath.substring(PATH_DELIMITER.length());
|
||||
}
|
||||
auditPath = auditPath.toLowerCase();
|
||||
for (CMISChangeType changeType : CMISChangeType.values())
|
||||
{
|
||||
if (auditPath.startsWith(changeType.getLabel()))
|
||||
{
|
||||
result = changeType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private class EntryIdCallback implements AuditQueryCallback
|
||||
{
|
||||
private final boolean valuesRequired;
|
||||
private Long entryId;
|
||||
|
||||
public EntryIdCallback(boolean valuesRequired)
|
||||
{
|
||||
this.valuesRequired = valuesRequired;
|
||||
}
|
||||
|
||||
public String getEntryId()
|
||||
{
|
||||
return entryId == null ? null : entryId.toString();
|
||||
}
|
||||
|
||||
public boolean valuesRequired()
|
||||
{
|
||||
return this.valuesRequired;
|
||||
}
|
||||
|
||||
public final boolean handleAuditEntry(Long entryId, String applicationName, String user, long time, Map<String, Serializable> values)
|
||||
{
|
||||
if (applicationName.equals(CMISChangeLogServiceImpl.this.cmisAuditApplicationName))
|
||||
{
|
||||
return handleAuditEntry(entryId, user, time, values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleAuditEntry(Long entryId, String user, long time, Map<String, Serializable> values)
|
||||
{
|
||||
this.entryId = entryId;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(errorMsg, error);
|
||||
}
|
||||
};
|
||||
|
||||
private class PageStartEntryIdCallback extends EntryIdCallback
|
||||
{
|
||||
private final int pageSize;
|
||||
private int indexWithinPage;
|
||||
|
||||
public PageStartEntryIdCallback(int pageSize)
|
||||
{
|
||||
super(false);
|
||||
this.pageSize = pageSize;
|
||||
this.indexWithinPage = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleAuditEntry(Long entryId, String user, long time, Map<String, Serializable> values)
|
||||
{
|
||||
if (++this.indexWithinPage == this.pageSize)
|
||||
{
|
||||
this.indexWithinPage = 0;
|
||||
return super.handleAuditEntry(entryId, user, time, values);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,564 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISPropertyId;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.dictionary.DictionaryDAO;
|
||||
import org.alfresco.repo.dictionary.DictionaryListener;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||
|
||||
|
||||
/**
|
||||
* Common CMIS Dictionary Support including registry of Types.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public abstract class CMISAbstractDictionaryService extends AbstractLifecycleBean implements CMISDictionaryService, DictionaryListener
|
||||
{
|
||||
// Logger
|
||||
protected static final Log logger = LogFactory.getLog(CMISAbstractDictionaryService.class);
|
||||
|
||||
// service dependencies
|
||||
private DictionaryDAO dictionaryDAO;
|
||||
protected CMISMapping cmisMapping;
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
/**
|
||||
* Set the mapping service
|
||||
*
|
||||
* @param cmisMapping
|
||||
*/
|
||||
public void setCMISMapping(CMISMapping cmisMapping)
|
||||
{
|
||||
this.cmisMapping = cmisMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary Service
|
||||
*
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary DAO
|
||||
*
|
||||
* @param dictionaryDAO
|
||||
*/
|
||||
public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
|
||||
{
|
||||
this.dictionaryDAO = dictionaryDAO;
|
||||
}
|
||||
|
||||
public void setSingletonCache(SimpleCache<String, DictionaryRegistry> singletonCache)
|
||||
{
|
||||
this.singletonCache = singletonCache;
|
||||
}
|
||||
|
||||
|
||||
private final ReentrantReadWriteLock registryLock = new ReentrantReadWriteLock();
|
||||
private final WriteLock registryWriteLock = registryLock.writeLock();
|
||||
private final ReadLock registryReadLock = registryLock.readLock();
|
||||
// note: cache is tenant-aware (if using TransctionalCache impl)
|
||||
private SimpleCache<String, DictionaryRegistry> singletonCache; // eg. for cmisDictionaryRegistry
|
||||
private final String KEY_CMIS_DICTIONARY_REGISTRY = "key.cmisDictionaryRegistry";
|
||||
|
||||
/**
|
||||
* CMIS Dictionary registry
|
||||
*
|
||||
* Index of CMIS Type Definitions
|
||||
*/
|
||||
/*package*/ class DictionaryRegistry
|
||||
{
|
||||
// Type Definitions Index
|
||||
Map<QName, CMISAbstractTypeDefinition> typeDefsByQName = new HashMap<QName, CMISAbstractTypeDefinition>();
|
||||
Map<QName, CMISAbstractTypeDefinition> assocDefsByQName = new HashMap<QName, CMISAbstractTypeDefinition>();
|
||||
Map<CMISTypeId, CMISAbstractTypeDefinition> objectDefsByTypeId = new HashMap<CMISTypeId, CMISAbstractTypeDefinition>();
|
||||
Map<CMISTypeId, CMISTypeDefinition> typeDefsByTypeId = new HashMap<CMISTypeId, CMISTypeDefinition>();
|
||||
Map<String, CMISTypeDefinition> typeDefsByQueryName = new HashMap<String, CMISTypeDefinition>();
|
||||
List<CMISTypeDefinition> baseTypes = new ArrayList<CMISTypeDefinition>();
|
||||
|
||||
// Property Definitions Index
|
||||
Map<String, CMISPropertyDefinition> propDefsById = new HashMap<String, CMISPropertyDefinition>();
|
||||
Map<QName, CMISPropertyDefinition> propDefsByQName = new HashMap<QName, CMISPropertyDefinition>();
|
||||
Map<CMISPropertyId, CMISPropertyDefinition> propDefsByPropId = new HashMap<CMISPropertyId, CMISPropertyDefinition>();
|
||||
Map<String, CMISPropertyDefinition> propDefsByQueryName = new HashMap<String, CMISPropertyDefinition>();
|
||||
|
||||
/**
|
||||
* Register Type Definition
|
||||
*
|
||||
* @param typeDef
|
||||
*/
|
||||
public void registerTypeDefinition(CMISAbstractTypeDefinition typeDef)
|
||||
{
|
||||
CMISTypeDefinition existingTypeDef = objectDefsByTypeId.get(typeDef.getTypeId());
|
||||
if (existingTypeDef != null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Type " + typeDef.getTypeId() + " already registered");
|
||||
}
|
||||
|
||||
objectDefsByTypeId.put(typeDef.getTypeId(), typeDef);
|
||||
if (typeDef.isPublic())
|
||||
{
|
||||
QName typeQName = typeDef.getTypeId().getQName();
|
||||
if (typeQName != null)
|
||||
{
|
||||
if (typeDef instanceof CMISRelationshipTypeDefinition)
|
||||
{
|
||||
assocDefsByQName.put(typeQName, typeDef);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeDefsByQName.put(typeQName, typeDef);
|
||||
}
|
||||
}
|
||||
typeDefsByTypeId.put(typeDef.getTypeId(), typeDef);
|
||||
typeDefsByQueryName.put(typeDef.getQueryName().toLowerCase(), typeDef);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Registered type " + typeDef.getTypeId() + " (scope=" + typeDef.getTypeId().getScope() + ", public=" + typeDef.isPublic() + ")");
|
||||
logger.debug(" QName: " + typeDef.getTypeId().getQName());
|
||||
logger.debug(" Table: " + typeDef.getQueryName());
|
||||
logger.debug(" Action Evaluators: " + typeDef.getActionEvaluators().size());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registry Property Definition
|
||||
*
|
||||
* @param propDef
|
||||
*/
|
||||
public void registerPropertyDefinition(CMISPropertyDefinition propDef)
|
||||
{
|
||||
CMISPropertyDefinition existingPropDef = propDefsByPropId.get(propDef.getPropertyId());
|
||||
if (existingPropDef != null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property " + propDef.getPropertyId() + " of " + propDef.getOwningType().getTypeId() + " already registered by type " + existingPropDef.getOwningType().getTypeId());
|
||||
}
|
||||
|
||||
propDefsByPropId.put(propDef.getPropertyId(), propDef);
|
||||
propDefsByQName.put(propDef.getPropertyId().getQName(), propDef);
|
||||
propDefsById.put(propDef.getPropertyId().getId().toLowerCase(), propDef);
|
||||
propDefsByQueryName.put(propDef.getQueryName().toLowerCase(), propDef);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Registered property " + propDef.getPropertyId().getId());
|
||||
logger.debug(" QName: " + propDef.getPropertyId().getQName());
|
||||
logger.debug(" Id: " + propDef.getPropertyId().getId());
|
||||
logger.debug(" Owning Type: " + propDef.getOwningType().getTypeId());
|
||||
logger.debug(" Property Accessor: " + propDef.getPropertyAccessor() + " , mappedProperty=" + propDef.getPropertyAccessor().getMappedProperty());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DictionaryRegistry[");
|
||||
builder.append("Types=").append(typeDefsByTypeId.size()).append(", ");
|
||||
builder.append("Base Types=").append(baseTypes.size()).append(", ");
|
||||
builder.append("Properties=").append(propDefsByPropId.size());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
protected DictionaryRegistry getRegistry()
|
||||
{
|
||||
return getRegistryImpl();
|
||||
}
|
||||
|
||||
protected DictionaryRegistry getRegistryImpl()
|
||||
{
|
||||
DictionaryRegistry registry = null;
|
||||
|
||||
registryReadLock.lock();
|
||||
try
|
||||
{
|
||||
registry = singletonCache.get(KEY_CMIS_DICTIONARY_REGISTRY);
|
||||
}
|
||||
finally
|
||||
{
|
||||
registryReadLock.unlock();
|
||||
}
|
||||
|
||||
if (registry == null)
|
||||
{
|
||||
init();
|
||||
registry = singletonCache.get(KEY_CMIS_DICTIONARY_REGISTRY);
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findType(org.alfresco.cmis.dictionary.CMISTypeId)
|
||||
*/
|
||||
public CMISTypeDefinition findType(CMISTypeId typeId)
|
||||
{
|
||||
return getRegistry().objectDefsByTypeId.get(typeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findType(java.lang.String)
|
||||
*/
|
||||
public CMISTypeDefinition findType(String typeId)
|
||||
{
|
||||
CMISTypeId cmisTypeId = cmisMapping.getCmisTypeId(typeId);
|
||||
return findType(cmisTypeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findTypeForClass(org.alfresco.service.namespace.QName, org.alfresco.cmis.dictionary.CMISScope[])
|
||||
*/
|
||||
public CMISTypeDefinition findTypeForClass(QName clazz, CMISScope... matchingScopes)
|
||||
{
|
||||
// searching for relationship
|
||||
boolean scopeByRelationship = false;
|
||||
for (CMISScope scope : matchingScopes)
|
||||
{
|
||||
if (scope == CMISScope.RELATIONSHIP)
|
||||
{
|
||||
scopeByRelationship = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// locate type in registry
|
||||
CMISTypeDefinition typeDef = null;
|
||||
if (scopeByRelationship)
|
||||
{
|
||||
typeDef = getRegistry().assocDefsByQName.get(clazz);
|
||||
}
|
||||
else
|
||||
{
|
||||
typeDef = getRegistry().typeDefsByQName.get(clazz);
|
||||
if (typeDef == null)
|
||||
{
|
||||
typeDef = getRegistry().assocDefsByQName.get(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure matches one of provided matching scopes
|
||||
CMISTypeDefinition matchingTypeDef = (matchingScopes.length == 0) ? typeDef : null;
|
||||
if (typeDef != null)
|
||||
{
|
||||
for (CMISScope scope : matchingScopes)
|
||||
{
|
||||
if (typeDef.getTypeId().getScope() == scope)
|
||||
{
|
||||
matchingTypeDef = typeDef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matchingTypeDef;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#findTypeForTable(java.lang.String)
|
||||
*/
|
||||
public CMISTypeDefinition findTypeByQueryName(String queryName)
|
||||
{
|
||||
CMISTypeDefinition typeDef = getRegistry().typeDefsByQueryName.get(queryName.toLowerCase());
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISDictionaryService#findPropertyByQueryName(java.lang.String)
|
||||
*/
|
||||
public CMISPropertyDefinition findPropertyByQueryName(String queryName)
|
||||
{
|
||||
CMISPropertyDefinition propertyDef = getRegistry().propDefsByQueryName.get(queryName.toLowerCase());
|
||||
return propertyDef;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISDictionaryService#getBaseTypes()
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getBaseTypes()
|
||||
{
|
||||
return Collections.unmodifiableCollection(getRegistry().baseTypes);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getAllTypes()
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllTypes()
|
||||
{
|
||||
return Collections.unmodifiableCollection(getRegistry().typeDefsByTypeId.values());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getProperty(org.alfresco.service.namespace.QName, org.alfresco.cmis.dictionary.CMISTypeDefinition)
|
||||
*/
|
||||
public CMISPropertyDefinition findProperty(QName property, CMISTypeDefinition matchingType)
|
||||
{
|
||||
CMISPropertyDefinition propDef = getRegistry().propDefsByQName.get(property);
|
||||
return getProperty(propDef, matchingType);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getProperty(java.lang.String, org.alfresco.cmis.dictionary.CMISTypeDefinition)
|
||||
*/
|
||||
public CMISPropertyDefinition findProperty(String property, CMISTypeDefinition matchingType)
|
||||
{
|
||||
CMISPropertyDefinition propDef = getRegistry().propDefsById.get(property.toLowerCase());
|
||||
return getProperty(propDef, matchingType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property definition if part of specified type definition
|
||||
*
|
||||
* @param property
|
||||
* @param matchingType
|
||||
* @return property definition (if matches), or null (if not matches)
|
||||
*/
|
||||
private CMISPropertyDefinition getProperty(CMISPropertyDefinition property, CMISTypeDefinition matchingType)
|
||||
{
|
||||
boolean isMatchingType = (matchingType == null);
|
||||
if (property != null && matchingType != null)
|
||||
{
|
||||
Map<String, CMISPropertyDefinition> props = matchingType.getPropertyDefinitions();
|
||||
if (props.containsKey(property.getPropertyId().getId()))
|
||||
{
|
||||
isMatchingType = true;
|
||||
}
|
||||
}
|
||||
return isMatchingType ? property : null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISDictionaryService#getDataType(org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
public CMISDataTypeEnum findDataType(QName dataType)
|
||||
{
|
||||
return cmisMapping.getDataType(dataType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Factory for creating CMIS Definitions
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
abstract protected void createDefinitions(DictionaryRegistry registry);
|
||||
|
||||
|
||||
/**
|
||||
* Dictionary Initialisation - creates a new registry
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
registryWriteLock.lock();
|
||||
try
|
||||
{
|
||||
DictionaryRegistry registry = new DictionaryRegistry();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Creating type definitions...");
|
||||
|
||||
// phase 1: construct type definitions
|
||||
createDefinitions(registry);
|
||||
for (CMISAbstractTypeDefinition objectTypeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
Map<String, CMISPropertyDefinition> propDefs = objectTypeDef.createProperties(cmisMapping, dictionaryService);
|
||||
for (CMISPropertyDefinition propDef : propDefs.values())
|
||||
{
|
||||
registry.registerPropertyDefinition(propDef);
|
||||
}
|
||||
objectTypeDef.createSubTypes(cmisMapping, dictionaryService);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Linking type definitions...");
|
||||
|
||||
// phase 2: link together
|
||||
for (CMISAbstractTypeDefinition objectTypeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
objectTypeDef.resolveDependencies(registry);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Resolving type inheritance...");
|
||||
|
||||
// phase 3: resolve inheritance
|
||||
Map<Integer,List<CMISAbstractTypeDefinition>> order = new TreeMap<Integer, List<CMISAbstractTypeDefinition>>();
|
||||
for (CMISAbstractTypeDefinition typeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
// calculate class depth in hierarchy
|
||||
int depth = 0;
|
||||
CMISAbstractTypeDefinition parent = typeDef.getInternalParentType();
|
||||
while (parent != null)
|
||||
{
|
||||
depth = depth +1;
|
||||
parent = parent.getInternalParentType();
|
||||
}
|
||||
|
||||
// map class to depth
|
||||
List<CMISAbstractTypeDefinition> classes = order.get(depth);
|
||||
if (classes == null)
|
||||
{
|
||||
classes = new ArrayList<CMISAbstractTypeDefinition>();
|
||||
order.put(depth, classes);
|
||||
}
|
||||
classes.add(typeDef);
|
||||
}
|
||||
for (int depth = 0; depth < order.size(); depth++)
|
||||
{
|
||||
for (CMISAbstractTypeDefinition typeDef : order.get(depth))
|
||||
{
|
||||
typeDef.resolveInheritance(registry);
|
||||
}
|
||||
}
|
||||
|
||||
// phase 4: assert valid
|
||||
for (CMISAbstractTypeDefinition typeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
typeDef.assertComplete();
|
||||
}
|
||||
|
||||
// phase 5: register base types
|
||||
for (CMISAbstractTypeDefinition typeDef : registry.objectDefsByTypeId.values())
|
||||
{
|
||||
if (typeDef.isPublic() && typeDef.getParentType() == null)
|
||||
{
|
||||
registry.baseTypes.add(typeDef);
|
||||
}
|
||||
}
|
||||
|
||||
// publish new registry
|
||||
singletonCache.put(KEY_CMIS_DICTIONARY_REGISTRY, registry);
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info("Initialized CMIS Dictionary. Types:" + registry.typeDefsByTypeId.size() + ", Base Types:" + registry.baseTypes.size() + ", Properties:" + registry.propDefsByPropId.size());
|
||||
}
|
||||
finally
|
||||
{
|
||||
registryWriteLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.dictionary.DictionaryListener#onInit()
|
||||
*/
|
||||
public void onDictionaryInit()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.dictionary.DictionaryListener#afterInit()
|
||||
*/
|
||||
public void afterDictionaryInit()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.dictionary.DictionaryListener#afterDictionaryDestroy()
|
||||
*/
|
||||
public void afterDictionaryDestroy()
|
||||
{
|
||||
registryWriteLock.lock();
|
||||
try
|
||||
{
|
||||
singletonCache.remove(KEY_CMIS_DICTIONARY_REGISTRY);
|
||||
}
|
||||
finally
|
||||
{
|
||||
registryWriteLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onBootstrap(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
afterDictionaryInit();
|
||||
|
||||
// TODO revisit (for KS and/or 1.1)
|
||||
if (dictionaryDAO != null)
|
||||
{
|
||||
dictionaryDAO.register(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.error("DictionaryDAO is null - hence CMIS Dictionary not registered for updates");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.extensions.surf.util.AbstractLifecycleBean#onShutdown(org.springframework.context.ApplicationEvent)
|
||||
*/
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@@ -1,523 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISActionEvaluator;
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISPropertyId;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Object Type Definition
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public abstract class CMISAbstractTypeDefinition implements CMISTypeDefinition, Serializable
|
||||
{
|
||||
// Logger
|
||||
protected static final Log logger = LogFactory.getLog(CMISAbstractTypeDefinition.class);
|
||||
|
||||
private static final long serialVersionUID = -3131505923356013430L;
|
||||
|
||||
// Object type properties
|
||||
protected Boolean isPublic = null;
|
||||
protected ClassDefinition cmisClassDef = null;
|
||||
protected CMISTypeId objectTypeId = null;
|
||||
protected String objectTypeQueryName = null;
|
||||
protected String displayName = null;
|
||||
protected CMISTypeId parentTypeId = null;
|
||||
protected CMISTypeDefinition parentType = null;
|
||||
protected CMISAbstractTypeDefinition internalParentType = null;
|
||||
protected CMISTypeDefinition rootType = null;
|
||||
protected String description = null;
|
||||
protected Boolean creatable = null;
|
||||
protected Boolean queryable = null;
|
||||
protected Boolean fullTextIndexed = null;
|
||||
protected Boolean controllablePolicy = null;
|
||||
protected Boolean controllableACL = null;
|
||||
protected Boolean includedInSuperTypeQuery = null;
|
||||
protected Collection<CMISTypeId> subTypeIds = null;
|
||||
protected Collection<CMISTypeDefinition> subTypes = null;
|
||||
protected Map<String, CMISPropertyDefinition> properties = null;
|
||||
protected Map<String, CMISPropertyDefinition> inheritedProperties = null;
|
||||
protected Map<String, CMISPropertyDefinition> ownedProperties = null;
|
||||
protected Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> actionEvaluators = null;
|
||||
|
||||
|
||||
/*package*/ void assertComplete()
|
||||
{
|
||||
if (objectTypeId == null) throw new IllegalStateException("objectTypeId not specified");
|
||||
if (isPublic == null) throw new IllegalStateException("isPublic not specified; objectTypeId=" + objectTypeId);
|
||||
//if (cmisClassDef == null) throw new IllegalStateException("cmisClassDef not specified; objectTypeId=" + objectTypeId);
|
||||
if (objectTypeQueryName == null) throw new IllegalStateException("objectTypeQueryName not specified; objectTypeId=" + objectTypeId);
|
||||
if (displayName == null) throw new IllegalStateException("displayName not specified; objectTypeId=" + objectTypeId);
|
||||
//if (parentTypeId == null) throw new IllegalStateException("parentTypeId not specified; objectTypeId=" + objectTypeId);
|
||||
if (parentTypeId != null && internalParentType == null) throw new IllegalStateException("parentType not specified; objectTypeId=" + objectTypeId + ",parentTypeId=" + parentTypeId);
|
||||
if (rootType == null) throw new IllegalStateException("rootType not specified; objectTypeId=" + objectTypeId);
|
||||
if (description == null) throw new IllegalStateException("description not specified; objectTypeId=" + objectTypeId);
|
||||
if (creatable == null) throw new IllegalStateException("creatable not specified; objectTypeId=" + objectTypeId);
|
||||
if (queryable == null) throw new IllegalStateException("queryable not specified; objectTypeId=" + objectTypeId);
|
||||
if (fullTextIndexed == null) throw new IllegalStateException("fullTextIndexed not specified; objectTypeId=" + objectTypeId);
|
||||
if (controllablePolicy == null) throw new IllegalStateException("controllablePolicy not specified; objectTypeId=" + objectTypeId);
|
||||
if (controllableACL == null) throw new IllegalStateException("controllablePolicy not specified; objectTypeId=" + objectTypeId);
|
||||
if (includedInSuperTypeQuery == null) throw new IllegalStateException("includedInSuperTypeQuery not specified; objectTypeId=" + objectTypeId);
|
||||
if (subTypeIds == null) throw new IllegalStateException("subTypeIds not specified; objectTypeId=" + objectTypeId);
|
||||
if (subTypes == null) throw new IllegalStateException("subTypes not specified; objectTypeId=" + objectTypeId);
|
||||
if (properties == null) throw new IllegalStateException("properties not specified; objectTypeId=" + objectTypeId);
|
||||
if (inheritedProperties == null) throw new IllegalStateException("inheritedProperties not specified; objectTypeId=" + objectTypeId);
|
||||
if (ownedProperties == null) throw new IllegalStateException("inheritedProperties not specified; objectTypeId=" + objectTypeId);
|
||||
if (actionEvaluators == null) throw new IllegalStateException("actionEvaluators not specified; objectTypeId=" + objectTypeId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param dictionaryService
|
||||
* @return
|
||||
*/
|
||||
/*package*/ Map<String, CMISPropertyDefinition> createProperties(CMISMapping cmisMapping, DictionaryService dictionaryService)
|
||||
{
|
||||
// map properties directly defined on this type
|
||||
properties = new HashMap<String, CMISPropertyDefinition>();
|
||||
for (PropertyDefinition propDef : cmisClassDef.getProperties().values())
|
||||
{
|
||||
if (propDef.getContainerClass().equals(cmisClassDef) && !propDef.isOverride())
|
||||
{
|
||||
if (cmisMapping.getDataType(propDef.getDataType()) != null)
|
||||
{
|
||||
CMISPropertyDefinition cmisPropDef = createProperty(cmisMapping, dictionaryService, propDef);
|
||||
properties.put(cmisPropDef.getPropertyId().getId(), cmisPropDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Property Definition
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param propDef
|
||||
* @return
|
||||
*/
|
||||
private CMISPropertyDefinition createProperty(CMISMapping cmisMapping, DictionaryService dictionaryService, PropertyDefinition propDef)
|
||||
{
|
||||
QName propertyQName = propDef.getName();
|
||||
String propertyId = cmisMapping.getCmisPropertyId(propertyQName);
|
||||
CMISPropertyId cmisPropertyId = new CMISPropertyId(propertyQName, propertyId);
|
||||
return new CMISBasePropertyDefinition(cmisMapping, cmisPropertyId, dictionaryService, propDef, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Sub Types
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param dictionaryService
|
||||
*/
|
||||
/*package*/ void createSubTypes(CMISMapping cmisMapping, DictionaryService dictionaryService)
|
||||
{
|
||||
subTypeIds = new ArrayList<CMISTypeId>();
|
||||
Collection<QName> subTypes = dictionaryService.getSubTypes(objectTypeId.getQName(), false);
|
||||
for (QName subType : subTypes)
|
||||
{
|
||||
if (cmisMapping.isValidCmisDocumentOrFolder(subType))
|
||||
{
|
||||
CMISTypeId subTypeId = cmisMapping.getCmisTypeId(subType);
|
||||
if (subTypeId != null)
|
||||
{
|
||||
subTypeIds.add(subTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve Dependencies
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
/*package*/ void resolveDependencies(DictionaryRegistry registry)
|
||||
{
|
||||
if (parentTypeId != null)
|
||||
{
|
||||
internalParentType = registry.objectDefsByTypeId.get(parentTypeId);
|
||||
if (internalParentType == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve parent type for type id " + parentTypeId);
|
||||
}
|
||||
if (internalParentType.isPublic() == isPublic)
|
||||
{
|
||||
parentType = internalParentType;
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + ": parent=" + (parentType == null ? "<none>" : parentType.getTypeId()) +
|
||||
", internal parent=" + (internalParentType == null ? "<none>" : internalParentType.getTypeId()));
|
||||
|
||||
CMISTypeId rootTypeId = objectTypeId.getBaseTypeId();
|
||||
if (rootTypeId != null)
|
||||
{
|
||||
rootType = registry.objectDefsByTypeId.get(rootTypeId);
|
||||
if (rootType == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve root type for type id " + rootTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + ": root=" + rootType.getTypeId());
|
||||
|
||||
subTypes = new ArrayList<CMISTypeDefinition>();
|
||||
for (CMISTypeId subTypeId : subTypeIds)
|
||||
{
|
||||
CMISTypeDefinition subType = registry.objectDefsByTypeId.get(subTypeId);
|
||||
if (subType == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve sub type for type id " + subTypeId + " for parent type " + objectTypeId);
|
||||
}
|
||||
if (subType.isPublic() == isPublic)
|
||||
{
|
||||
subTypes.add(subType);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + ": subtype=" + subType.getTypeId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve Inheritance
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
/*package*/ void resolveInheritance(DictionaryRegistry registry)
|
||||
{
|
||||
inheritedProperties = new HashMap<String, CMISPropertyDefinition>();
|
||||
ownedProperties = new HashMap<String, CMISPropertyDefinition>();
|
||||
inheritedProperties.putAll(properties);
|
||||
ownedProperties.putAll(properties);
|
||||
if (internalParentType != null)
|
||||
{
|
||||
inheritedProperties.putAll(internalParentType.getPropertyDefinitions());
|
||||
|
||||
// collapse all internal inherited properties into owned properties
|
||||
if (internalParentType.isPublic != isPublic)
|
||||
{
|
||||
ownedProperties.putAll(internalParentType.getPropertyDefinitions());
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + " inheriting properties: " + internalParentType.getPropertyDefinitions().size() + " from " + internalParentType.getTypeId());
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + " properties: " + inheritedProperties.size() + ", owned: " + ownedProperties.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get internal parent type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISAbstractTypeDefinition getInternalParentType()
|
||||
{
|
||||
return internalParentType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isPublic()
|
||||
*/
|
||||
public boolean isPublic()
|
||||
{
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getTypeId()
|
||||
*/
|
||||
public CMISTypeId getTypeId()
|
||||
{
|
||||
return objectTypeId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getQueryName()
|
||||
*/
|
||||
public String getQueryName()
|
||||
{
|
||||
return objectTypeQueryName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getDisplayName()
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getParentType()
|
||||
*/
|
||||
public CMISTypeDefinition getParentType()
|
||||
{
|
||||
return parentType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getRootType()
|
||||
*/
|
||||
public CMISTypeDefinition getBaseType()
|
||||
{
|
||||
return rootType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getSubTypes(boolean)
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getSubTypes(boolean includeDescendants)
|
||||
{
|
||||
if (!includeDescendants)
|
||||
{
|
||||
return subTypes;
|
||||
}
|
||||
|
||||
// recurse sub-type hierarchy
|
||||
Collection<CMISTypeDefinition> descendants = new ArrayList<CMISTypeDefinition>();
|
||||
LinkedList<CMISTypeDefinition> stack = new LinkedList<CMISTypeDefinition>();
|
||||
stack.addLast(this);
|
||||
while (stack.size() > 0)
|
||||
{
|
||||
CMISTypeDefinition current = stack.removeLast();
|
||||
if (!current.equals(this)) // do not add this type
|
||||
{
|
||||
descendants.add(current);
|
||||
}
|
||||
|
||||
// descend...
|
||||
for (CMISTypeDefinition type : current.getSubTypes(false))
|
||||
{
|
||||
stack.addLast(type);
|
||||
}
|
||||
}
|
||||
return descendants;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getDescription()
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isCreatable()
|
||||
*/
|
||||
public boolean isCreatable()
|
||||
{
|
||||
return creatable;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isQueryable()
|
||||
*/
|
||||
public boolean isQueryable()
|
||||
{
|
||||
return queryable;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISTypeDefinition#isFullTextIndexed()
|
||||
*/
|
||||
public boolean isFullTextIndexed()
|
||||
{
|
||||
return fullTextIndexed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isControllable()
|
||||
*/
|
||||
public boolean isControllablePolicy()
|
||||
{
|
||||
return controllablePolicy;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISTypeDefinition#isControllableACL()
|
||||
*/
|
||||
public boolean isControllableACL()
|
||||
{
|
||||
return controllableACL;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isIncludedInSuperTypeQuery()
|
||||
*/
|
||||
public boolean isIncludedInSuperTypeQuery()
|
||||
{
|
||||
return includedInSuperTypeQuery;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getPropertyDefinitions()
|
||||
*/
|
||||
public Map<String, CMISPropertyDefinition> getPropertyDefinitions()
|
||||
{
|
||||
return inheritedProperties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getOwnedPropertyDefinitions()
|
||||
*/
|
||||
public Map<String, CMISPropertyDefinition> getOwnedPropertyDefinitions()
|
||||
{
|
||||
return ownedProperties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISTypeDefinition#getActionEvaluators()
|
||||
*/
|
||||
public Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> getActionEvaluators()
|
||||
{
|
||||
return actionEvaluators;
|
||||
}
|
||||
|
||||
//
|
||||
// Document Type specific
|
||||
//
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isFileable()
|
||||
*/
|
||||
public boolean isFileable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#isVersionable()
|
||||
*/
|
||||
public boolean isVersionable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getContentStreamAllowed()
|
||||
*/
|
||||
public CMISContentStreamAllowedEnum getContentStreamAllowed()
|
||||
{
|
||||
return CMISContentStreamAllowedEnum.NOT_ALLOWED;
|
||||
}
|
||||
|
||||
//
|
||||
// Relationship Type specific
|
||||
//
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getAllowedSourceTypes()
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedSourceTypes()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getAllowedTargetTypes()
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedTargetTypes()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return objectTypeId.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final CMISTypeDefinition other = (CMISTypeDefinition) obj;
|
||||
if (objectTypeId == null)
|
||||
{
|
||||
if (other.getTypeId() != null)
|
||||
return false;
|
||||
}
|
||||
else if (!objectTypeId.equals(other.getTypeId()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -1,420 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.alfresco.cmis.CMISCardinalityEnum;
|
||||
import org.alfresco.cmis.CMISChoice;
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISPropertyAccessor;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISPropertyId;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISUpdatabilityEnum;
|
||||
import org.alfresco.cmis.mapping.AbstractProperty;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
|
||||
import org.alfresco.repo.dictionary.IndexTokenisationMode;
|
||||
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
|
||||
import org.alfresco.repo.dictionary.constraint.NumericRangeConstraint;
|
||||
import org.alfresco.repo.dictionary.constraint.StringLengthConstraint;
|
||||
import org.alfresco.service.cmr.dictionary.Constraint;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.util.ISO9075;
|
||||
|
||||
/**
|
||||
* CMIS Property Definition
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -8119257313852558466L;
|
||||
|
||||
// Properties of Property
|
||||
private CMISTypeDefinition typeDef;
|
||||
|
||||
private CMISPropertyId propertyId;
|
||||
|
||||
private String queryName;
|
||||
|
||||
private String displayName;
|
||||
|
||||
private String description;
|
||||
|
||||
private CMISDataTypeEnum propertyType;
|
||||
|
||||
private CMISCardinalityEnum cardinality;
|
||||
|
||||
private Double minValue = null;
|
||||
|
||||
private Double maxValue = null;
|
||||
|
||||
private int maximumLength = -1;
|
||||
|
||||
private Collection<CMISChoice> choices = new HashSet<CMISChoice>();
|
||||
|
||||
private boolean isOpenChoice = false;
|
||||
|
||||
private boolean required;
|
||||
|
||||
private String defaultValue;
|
||||
|
||||
private CMISUpdatabilityEnum updatability;
|
||||
|
||||
private boolean queryable;
|
||||
|
||||
private boolean orderable;
|
||||
|
||||
private AbstractProperty propertyAccessor;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param propertyId
|
||||
* @param propDef
|
||||
* @param typeDef
|
||||
*/
|
||||
public CMISBasePropertyDefinition(CMISMapping cmisMapping, CMISPropertyId propertyId, DictionaryService dictionaryService, PropertyDefinition propDef,
|
||||
CMISTypeDefinition typeDef)
|
||||
{
|
||||
this.propertyId = propertyId;
|
||||
this.typeDef = typeDef;
|
||||
queryName = ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(propertyId.getQName()));
|
||||
displayName = (propDef.getTitle(dictionaryService) != null) ? propDef.getTitle(dictionaryService) : propertyId.getId();
|
||||
description = propDef.getDescription(dictionaryService) != null ? propDef.getDescription(dictionaryService) : displayName;
|
||||
propertyType = cmisMapping.getDataType(propDef.getDataType());
|
||||
cardinality = propDef.isMultiValued() ? CMISCardinalityEnum.MULTI_VALUED : CMISCardinalityEnum.SINGLE_VALUED;
|
||||
for (ConstraintDefinition constraintDef : propDef.getConstraints())
|
||||
{
|
||||
Constraint constraint = constraintDef.getConstraint();
|
||||
if (constraint instanceof ListOfValuesConstraint)
|
||||
{
|
||||
int position = 1; // CMIS is 1 based (according to XSDs)
|
||||
ListOfValuesConstraint lovc = (ListOfValuesConstraint) constraint;
|
||||
for (String allowed : lovc.getAllowedValues())
|
||||
{
|
||||
CMISChoice choice = new CMISChoice(allowed, allowed, position++);
|
||||
choices.add(choice);
|
||||
}
|
||||
}
|
||||
if (constraint instanceof StringLengthConstraint)
|
||||
{
|
||||
StringLengthConstraint slc = (StringLengthConstraint) constraint;
|
||||
maximumLength = slc.getMaxLength();
|
||||
}
|
||||
if (constraint instanceof NumericRangeConstraint)
|
||||
{
|
||||
NumericRangeConstraint nrc = (NumericRangeConstraint) constraint;
|
||||
minValue = nrc.getMinValue();
|
||||
maxValue = nrc.getMaxValue();
|
||||
}
|
||||
}
|
||||
required = propDef.isMandatory();
|
||||
defaultValue = propDef.getDefaultValue();
|
||||
if (propertyId.getId().equals(CMISDictionaryModel.PROP_OBJECT_TYPE_ID)
|
||||
|| propertyId.getId().equals(CMISDictionaryModel.PROP_SOURCE_ID)
|
||||
|| propertyId.getId().equals(CMISDictionaryModel.PROP_TARGET_ID))
|
||||
{
|
||||
// Fix http://issues.alfresco.com/jira/browse/ALF-2637
|
||||
updatability = CMISUpdatabilityEnum.ON_CREATE;
|
||||
} else
|
||||
{
|
||||
updatability = propDef.isProtected() ? CMISUpdatabilityEnum.READ_ONLY : CMISUpdatabilityEnum.READ_AND_WRITE;
|
||||
}
|
||||
queryable = propDef.isIndexed();
|
||||
if (queryable)
|
||||
{
|
||||
if (cardinality == CMISCardinalityEnum.SINGLE_VALUED)
|
||||
{
|
||||
IndexTokenisationMode indexTokenisationMode = IndexTokenisationMode.TRUE;
|
||||
if (propDef.getIndexTokenisationMode() != null)
|
||||
{
|
||||
indexTokenisationMode = propDef.getIndexTokenisationMode();
|
||||
}
|
||||
switch (indexTokenisationMode)
|
||||
{
|
||||
case BOTH:
|
||||
case FALSE:
|
||||
orderable = true;
|
||||
break;
|
||||
case TRUE:
|
||||
default:
|
||||
if (propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.DATE)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.DATETIME)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.INT)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.LONG)
|
||||
|| propDef.getDataType().getName().equals(DataTypeDefinition.PATH)
|
||||
)
|
||||
{
|
||||
orderable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
orderable = false;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
orderable = false;
|
||||
}
|
||||
} else
|
||||
{
|
||||
orderable = false;
|
||||
}
|
||||
propertyAccessor = cmisMapping.getPropertyAccessor(propertyId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Property Id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyId getPropertyId()
|
||||
{
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Owning Type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeDefinition getOwningType()
|
||||
{
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getQueryName()
|
||||
{
|
||||
return queryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the description
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the property type
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISDataTypeEnum getDataType()
|
||||
{
|
||||
return propertyType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cardinality
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISCardinalityEnum getCardinality()
|
||||
{
|
||||
return cardinality;
|
||||
}
|
||||
|
||||
/**
|
||||
* For variable length properties, get the maximum length allowed.
|
||||
* Unsupported.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getMaximumLength()
|
||||
{
|
||||
return maximumLength;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISPropertyDefinition#getMinValue()
|
||||
*/
|
||||
public Double getMinValue()
|
||||
{
|
||||
return minValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISPropertyDefinition#getMaxValue()
|
||||
*/
|
||||
public Double getMaxValue()
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the choices available as values for this property TODO: not
|
||||
* implemented yet
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISChoice> getChoices()
|
||||
{
|
||||
return choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a choice where a user can enter other values (ie a list with
|
||||
* common options)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOpenChoice()
|
||||
{
|
||||
return isOpenChoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this property required?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isRequired()
|
||||
{
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the default value as a String
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultValue()
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this property updatable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISUpdatabilityEnum getUpdatability()
|
||||
{
|
||||
return updatability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this property queryable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isQueryable()
|
||||
{
|
||||
return queryable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this property orderable in queries?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOrderable()
|
||||
{
|
||||
return orderable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property accessor (for reading / writing values)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyAccessor getPropertyAccessor()
|
||||
{
|
||||
return propertyAccessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property Lucene builder
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISPropertyLuceneBuilder getPropertyLuceneBuilder()
|
||||
{
|
||||
return propertyAccessor;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CMISPropertyDefinition[");
|
||||
builder.append("OwningTypeId=").append(getOwningType().getTypeId()).append(", ");
|
||||
builder.append("Id=").append(getPropertyId().getId()).append(", ");
|
||||
builder.append("LocalName=").append(getPropertyId().getLocalName()).append(", ");
|
||||
builder.append("Namespace=").append(getPropertyId().getLocalNamespace()).append(", ");
|
||||
builder.append("InternalQName=").append(getPropertyId().getQName()).append(", ");
|
||||
builder.append("QueryName=").append(getQueryName()).append(", ");
|
||||
builder.append("DisplayName=").append(getDisplayName()).append(", ");
|
||||
builder.append("Description=").append(getDescription()).append(", ");
|
||||
builder.append("PropertyType=").append(getDataType()).append(", ");
|
||||
builder.append("Cardinality=").append(getCardinality()).append(", ");
|
||||
builder.append("MaximumLength=").append(getMaximumLength()).append(", ");
|
||||
builder.append("Choices=").append(getChoices()).append(", ");
|
||||
builder.append("IsOpenChoice=").append(isOpenChoice()).append(", ");
|
||||
builder.append("Required=").append(isRequired()).append(", ");
|
||||
builder.append("Default=").append(getDefaultValue()).append(", ");
|
||||
builder.append("Updatable=").append(getUpdatability()).append(", ");
|
||||
builder.append("Queryable=").append(isQueryable()).append(", ");
|
||||
builder.append("Orderable=").append(isOrderable());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Document Type Definition
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISDocumentTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = -7209732754962781522L;
|
||||
|
||||
// document specific properties
|
||||
protected boolean fileable;
|
||||
protected CMISContentStreamAllowedEnum contentStreamAllowed;
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param typeId
|
||||
* @param cmisClassDef
|
||||
*/
|
||||
public CMISDocumentTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
|
||||
{
|
||||
isPublic = true;
|
||||
|
||||
// Object type properties
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
displayName = (cmisClassDef.getTitle(dictionaryService) != null) ? cmisClassDef.getTitle(dictionaryService) : typeId.getId();
|
||||
description = cmisClassDef.getDescription(dictionaryService) != null ? cmisClassDef.getDescription(dictionaryService) : displayName;
|
||||
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (typeId == CMISDictionaryModel.DOCUMENT_TYPE_ID)
|
||||
{
|
||||
objectTypeQueryName = typeId.getId();
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objectTypeQueryName = ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(typeId.getQName()));
|
||||
if (cmisMapping.isValidCmisDocument(parentQName))
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.DOCUMENT, parentQName);
|
||||
}
|
||||
}
|
||||
|
||||
creatable = true;
|
||||
queryable = true;
|
||||
fullTextIndexed = true;
|
||||
controllablePolicy = false;
|
||||
controllableACL = true;
|
||||
includedInSuperTypeQuery = cmisClassDef.getIncludedInSuperTypeQuery();
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
|
||||
|
||||
fileable = true;
|
||||
contentStreamAllowed = CMISContentStreamAllowedEnum.ALLOWED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are objects of this type fileable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isFileable()
|
||||
{
|
||||
return fileable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this type versionable? If true this implies all instances of the type are versionable.
|
||||
*
|
||||
* @return true if versionable
|
||||
*/
|
||||
public boolean isVersionable()
|
||||
{
|
||||
// Documents and their subtypes are versionable
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a content stream allowed for this type? It may be disallowed, optional or mandatory.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CMISContentStreamAllowedEnum getContentStreamAllowed()
|
||||
{
|
||||
return contentStreamAllowed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CMISDocumentTypeDefinition[");
|
||||
builder.append("Id=").append(getTypeId().getId()).append(", ");
|
||||
builder.append("Namespace=").append(getTypeId().getLocalNamespace()).append(", ");
|
||||
builder.append("LocalName=").append(getTypeId().getLocalName()).append(", ");
|
||||
builder.append("QueryName=").append(getQueryName()).append(", ");
|
||||
builder.append("DisplayName=").append(getDisplayName()).append(", ");
|
||||
builder.append("ParentId=").append(getParentType() == null ? "<none>" : getParentType().getTypeId()).append(", ");
|
||||
builder.append("Description=").append(getDescription()).append(", ");
|
||||
builder.append("Creatable=").append(isCreatable()).append(", ");
|
||||
builder.append("Queryable=").append(isQueryable()).append(", ");
|
||||
builder.append("FullTextIndexed=").append(isFullTextIndexed()).append(", ");
|
||||
builder.append("IncludedInSuperTypeQuery=").append(isIncludedInSuperTypeQuery()).append(", ");
|
||||
builder.append("ControllablePolicy=").append(isControllablePolicy()).append(", ");
|
||||
builder.append("ControllableACL=").append(isControllableACL()).append(", ");
|
||||
builder.append("Fileable=").append(isFileable()).append(", ");
|
||||
builder.append("Versionable=").append(isVersionable()).append(", ");
|
||||
builder.append("ContentStreamAllowed=").append(getContentStreamAllowed()).append(", ");
|
||||
builder.append("SubTypes=").append(getSubTypes(false).size()).append(", ");
|
||||
builder.append("Properties=").append(getPropertyDefinitions().size());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Folder Type Definition
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISFolderTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = 7526155195125799106L;
|
||||
|
||||
protected final boolean fileable = true;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
* @param cmisMapping
|
||||
* @param typeId
|
||||
* @param cmisClassDef
|
||||
*/
|
||||
public CMISFolderTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef, boolean isSystem)
|
||||
{
|
||||
isPublic = true;
|
||||
|
||||
// Object type properties
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
displayName = (cmisClassDef.getTitle(dictionaryService) != null) ? cmisClassDef.getTitle(dictionaryService) : typeId.getId();
|
||||
description = cmisClassDef.getDescription(dictionaryService) != null ? cmisClassDef.getDescription(dictionaryService) : displayName;
|
||||
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (typeId == CMISDictionaryModel.FOLDER_TYPE_ID)
|
||||
{
|
||||
objectTypeQueryName = typeId.getId();
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objectTypeQueryName = ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(typeId.getQName()));
|
||||
if (cmisMapping.isValidCmisFolder(parentQName))
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.FOLDER, parentQName);
|
||||
}
|
||||
}
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
|
||||
|
||||
// TODO: introduce abstract into core alfresco content metamodel
|
||||
creatable = !isSystem;
|
||||
queryable = true;
|
||||
fullTextIndexed = true;
|
||||
controllablePolicy = false;
|
||||
controllableACL = true;
|
||||
includedInSuperTypeQuery = cmisClassDef.getIncludedInSuperTypeQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Are objects of this type fileable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isFileable()
|
||||
{
|
||||
return fileable;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CMISFolderTypeDefinition[");
|
||||
builder.append("Id=").append(getTypeId().getId()).append(", ");
|
||||
builder.append("Namespace=").append(getTypeId().getLocalNamespace()).append(", ");
|
||||
builder.append("LocalName=").append(getTypeId().getLocalName()).append(", ");
|
||||
builder.append("QueryName=").append(getQueryName()).append(", ");
|
||||
builder.append("DisplayName=").append(getDisplayName()).append(", ");
|
||||
builder.append("ParentId=").append(getParentType() == null ? "<none>" : getParentType().getTypeId()).append(", ");
|
||||
builder.append("Description=").append(getDescription()).append(", ");
|
||||
builder.append("Creatable=").append(isCreatable()).append(", ");
|
||||
builder.append("Queryable=").append(isQueryable()).append(", ");
|
||||
builder.append("FullTextIndexed=").append(isFullTextIndexed()).append(", ");
|
||||
builder.append("IncludedInSuperTypeQuery=").append(isIncludedInSuperTypeQuery()).append(", ");
|
||||
builder.append("ControllablePolicy=").append(isControllablePolicy()).append(", ");
|
||||
builder.append("ControllableACL=").append(isControllableACL()).append(", ");
|
||||
builder.append("Fileable=").append(isFileable()).append(", ");
|
||||
builder.append("SubTypes=").append(getSubTypes(false).size()).append(", ");
|
||||
builder.append("Properties=").append(getPropertyDefinitions().size());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Object Type Definition
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISObjectTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = -3131505923356013430L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param typeId
|
||||
* @param cmisClassDef
|
||||
*/
|
||||
public CMISObjectTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef, boolean isPublic)
|
||||
{
|
||||
this.isPublic = isPublic;
|
||||
|
||||
// Object type properties
|
||||
objectTypeId = typeId;
|
||||
objectTypeQueryName = ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(typeId.getQName()));
|
||||
|
||||
if (cmisClassDef != null)
|
||||
{
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
displayName = (cmisClassDef.getTitle(dictionaryService) != null) ? cmisClassDef.getTitle(dictionaryService) : typeId.getId();
|
||||
description = cmisClassDef.getDescription(dictionaryService) != null ? cmisClassDef.getDescription(dictionaryService) : displayName;
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
includedInSuperTypeQuery = cmisClassDef.getIncludedInSuperTypeQuery();
|
||||
}
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
|
||||
|
||||
creatable = false;
|
||||
queryable = false;
|
||||
fullTextIndexed = false;
|
||||
controllablePolicy = false;
|
||||
controllableACL = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Sub Types
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param dictionaryService
|
||||
*/
|
||||
/*package*/ void createSubTypes(CMISMapping cmisMapping, DictionaryService dictionaryService)
|
||||
{
|
||||
subTypeIds = new ArrayList<CMISTypeId>();
|
||||
Collection<QName> subTypes = dictionaryService.getSubTypes(objectTypeId.getQName(), false);
|
||||
for (QName subType : subTypes)
|
||||
{
|
||||
CMISTypeId subTypeId = cmisMapping.getCmisTypeId(subType);
|
||||
if (subTypeId != null)
|
||||
{
|
||||
subTypeIds.add(subTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CMISObjectTypeDefinition[");
|
||||
builder.append("Public=").append(isPublic()).append(", ");
|
||||
builder.append("ObjectTypeId=").append(getTypeId()).append(", ");
|
||||
builder.append("ObjectTypeQueryName=").append(getQueryName()).append(", ");
|
||||
builder.append("ObjectTypeDisplayName=").append(getDisplayName()).append(", ");
|
||||
builder.append("ParentTypeId=").append(getParentType() == null ? "<none>" : getParentType().getTypeId()).append(", ");
|
||||
builder.append("Description=").append(getDescription()).append(", ");
|
||||
builder.append("Creatable=").append(isCreatable()).append(", ");
|
||||
builder.append("Queryable=").append(isQueryable()).append(", ");
|
||||
builder.append("Controllable=").append(isControllablePolicy()).append(", ");
|
||||
builder.append("IncludedInSuperTypeQuery=").append(isIncludedInSuperTypeQuery()).append(", ");
|
||||
builder.append("SubTypes=").append(getSubTypes(false).size()).append(", ");
|
||||
builder.append("Properties=").append(getPropertyDefinitions().size());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Policy Type Definition
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISPolicyTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = 1621538303752395828L;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param typeId
|
||||
* @param cmisClassDef
|
||||
*/
|
||||
public CMISPolicyTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef)
|
||||
{
|
||||
isPublic = true;
|
||||
|
||||
// Object Type definitions
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
displayName = (cmisClassDef.getTitle(dictionaryService) != null) ? cmisClassDef.getTitle(dictionaryService) : typeId.getId();
|
||||
if (typeId == CMISDictionaryModel.POLICY_TYPE_ID)
|
||||
{
|
||||
objectTypeQueryName = typeId.getId();
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
objectTypeQueryName = ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(typeId.getQName()));
|
||||
parentTypeId = CMISDictionaryModel.POLICY_TYPE_ID;
|
||||
}
|
||||
description = cmisClassDef.getDescription(dictionaryService) != null ? cmisClassDef.getDescription(dictionaryService) : displayName;
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
|
||||
|
||||
creatable = false;
|
||||
queryable = true;
|
||||
includedInSuperTypeQuery = cmisClassDef.getIncludedInSuperTypeQuery();
|
||||
fullTextIndexed = true;
|
||||
controllablePolicy = false;
|
||||
controllableACL = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISObjectTypeDefinition#createSubTypes(org.alfresco.cmis.dictionary.CMISMapping, org.alfresco.service.cmr.dictionary.DictionaryService)
|
||||
*/
|
||||
@Override
|
||||
/*package*/ void createSubTypes(CMISMapping cmisMapping, DictionaryService dictionaryService)
|
||||
{
|
||||
subTypeIds = new ArrayList<CMISTypeId>();
|
||||
if (objectTypeId.equals(CMISDictionaryModel.POLICY_TYPE_ID))
|
||||
{
|
||||
// all aspects are sub-type of POLICY_OBJECT_TYPE
|
||||
Collection<QName> aspects = dictionaryService.getAllAspects();
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
if (cmisMapping.isValidCmisPolicy(aspect))
|
||||
{
|
||||
subTypeIds.add(cmisMapping.getCmisTypeId(CMISScope.POLICY, aspect));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISObjectTypeDefinition#resolveInheritance(org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry)
|
||||
*/
|
||||
@Override
|
||||
/*package*/ void resolveInheritance(DictionaryRegistry registry)
|
||||
{
|
||||
inheritedProperties = new HashMap<String, CMISPropertyDefinition>();
|
||||
ownedProperties = new HashMap<String, CMISPropertyDefinition>();
|
||||
// NOTE: Force no inheritance of base Policy type
|
||||
inheritedProperties.putAll(properties);
|
||||
ownedProperties.putAll(properties);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Type " + objectTypeId + " properties: " + inheritedProperties.size() + ", owned: " + ownedProperties.size());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CMISPolicyTypeDefinition[");
|
||||
builder.append("Id=").append(getTypeId().getId()).append(", ");
|
||||
builder.append("Namespace=").append(getTypeId().getLocalNamespace()).append(", ");
|
||||
builder.append("LocalName=").append(getTypeId().getLocalName()).append(", ");
|
||||
builder.append("QueryName=").append(getQueryName()).append(", ");
|
||||
builder.append("DisplayName=").append(getDisplayName()).append(", ");
|
||||
builder.append("ParentId=").append(getParentType() == null ? "<none>" : getParentType().getTypeId()).append(", ");
|
||||
builder.append("Description=").append(getDescription()).append(", ");
|
||||
builder.append("Creatable=").append(isCreatable()).append(", ");
|
||||
builder.append("Queryable=").append(isQueryable()).append(", ");
|
||||
builder.append("Controllable=").append(isControllablePolicy()).append(", ");
|
||||
builder.append("IncludedInSuperTypeQuery=").append(isIncludedInSuperTypeQuery()).append(", ");
|
||||
builder.append("SubTypes=").append(getSubTypes(false).size()).append(", ");
|
||||
builder.append("Properties=").append(getPropertyDefinitions().size());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,264 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ISO9075;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Relationship Type Definition
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISRelationshipTypeDefinition extends CMISAbstractTypeDefinition
|
||||
{
|
||||
private static final long serialVersionUID = 5291428171784061346L;
|
||||
|
||||
// Relationship properties
|
||||
private List<CMISTypeId> allowedSourceTypeIds = new ArrayList<CMISTypeId>();
|
||||
private List<CMISTypeDefinition> allowedSourceTypes = new ArrayList<CMISTypeDefinition>();
|
||||
private List<CMISTypeDefinition> inheritedAllowedSourceTypes = new ArrayList<CMISTypeDefinition>();
|
||||
private List<CMISTypeId> allowedTargetTypeIds = new ArrayList<CMISTypeId>();
|
||||
private List<CMISTypeDefinition> allowedTargetTypes = new ArrayList<CMISTypeDefinition>();
|
||||
private List<CMISTypeDefinition> inheritedAllowedTargetTypes = new ArrayList<CMISTypeDefinition>();
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisMapping
|
||||
* @param typeId
|
||||
* @param cmisClassDef
|
||||
* @param assocDef
|
||||
*/
|
||||
public CMISRelationshipTypeDefinition(CMISMapping cmisMapping, CMISTypeId typeId, DictionaryService dictionaryService, ClassDefinition cmisClassDef, AssociationDefinition assocDef)
|
||||
{
|
||||
isPublic = true;
|
||||
this.cmisClassDef = cmisClassDef;
|
||||
objectTypeId = typeId;
|
||||
|
||||
actionEvaluators = cmisMapping.getActionEvaluators(objectTypeId.getScope());
|
||||
|
||||
queryable = false;
|
||||
fullTextIndexed = false;
|
||||
includedInSuperTypeQuery = true;
|
||||
controllablePolicy = false;
|
||||
controllableACL = false;
|
||||
|
||||
if (assocDef == null)
|
||||
{
|
||||
// TODO: Add CMIS Association mapping??
|
||||
creatable = false;
|
||||
displayName = (cmisClassDef.getTitle(dictionaryService) != null) ? cmisClassDef.getTitle(dictionaryService) : typeId.getId();
|
||||
objectTypeQueryName = typeId.getId();
|
||||
QName parentQName = cmisMapping.getCmisType(cmisClassDef.getParentName());
|
||||
if (parentQName != null)
|
||||
{
|
||||
parentTypeId = cmisMapping.getCmisTypeId(CMISScope.OBJECT, parentQName);
|
||||
}
|
||||
description = cmisClassDef.getDescription(dictionaryService) != null ? cmisClassDef.getDescription(dictionaryService) : displayName;
|
||||
}
|
||||
else
|
||||
{
|
||||
creatable = true;
|
||||
displayName = (assocDef.getTitle(dictionaryService) != null) ? assocDef.getTitle(dictionaryService) : typeId.getId();
|
||||
objectTypeQueryName = ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(typeId.getQName()));
|
||||
parentTypeId = CMISDictionaryModel.RELATIONSHIP_TYPE_ID;
|
||||
description = assocDef.getDescription(dictionaryService) != null ? assocDef.getDescription(dictionaryService) : displayName;
|
||||
|
||||
CMISTypeId sourceTypeId = cmisMapping.getCmisTypeId(cmisMapping.getCmisType(assocDef.getSourceClass().getName()));
|
||||
if (sourceTypeId != null)
|
||||
{
|
||||
allowedSourceTypeIds.add(sourceTypeId);
|
||||
}
|
||||
|
||||
CMISTypeId targetTypeId = cmisMapping.getCmisTypeId(cmisMapping.getCmisType(assocDef.getTargetClass().getName()));
|
||||
if (targetTypeId != null)
|
||||
{
|
||||
allowedTargetTypeIds.add(targetTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISObjectTypeDefinition#createProperties(org.alfresco.cmis.dictionary.CMISMapping, org.alfresco.service.cmr.dictionary.DictionaryService)
|
||||
*/
|
||||
@Override
|
||||
/*package*/ Map<String, CMISPropertyDefinition> createProperties(CMISMapping cmisMapping, DictionaryService dictionaryService)
|
||||
{
|
||||
if (objectTypeId.equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
|
||||
{
|
||||
return super.createProperties(cmisMapping, dictionaryService);
|
||||
}
|
||||
properties = new HashMap<String, CMISPropertyDefinition>();
|
||||
return properties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISObjectTypeDefinition#createSubTypes(org.alfresco.cmis.dictionary.CMISMapping, org.alfresco.service.cmr.dictionary.DictionaryService)
|
||||
*/
|
||||
@Override
|
||||
/*package*/ void createSubTypes(CMISMapping cmisMapping, DictionaryService dictionaryService)
|
||||
{
|
||||
subTypeIds = new ArrayList<CMISTypeId>();
|
||||
if (objectTypeId.equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID))
|
||||
{
|
||||
// all associations are sub-type of RELATIONSHIP_OBJECT_TYPE
|
||||
Collection<QName> assocs = dictionaryService.getAllAssociations();
|
||||
for (QName assoc : assocs)
|
||||
{
|
||||
if (cmisMapping.isValidCmisRelationship(assoc))
|
||||
{
|
||||
subTypeIds.add(cmisMapping.getCmisTypeId(CMISScope.RELATIONSHIP, assoc));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISObjectTypeDefinition#resolveDependencies(org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry)
|
||||
*/
|
||||
@Override
|
||||
/*package*/ void resolveDependencies(DictionaryRegistry registry)
|
||||
{
|
||||
super.resolveDependencies(registry);
|
||||
for (CMISTypeId sourceTypeId : allowedSourceTypeIds)
|
||||
{
|
||||
CMISTypeDefinition type = registry.objectDefsByTypeId.get(sourceTypeId);
|
||||
if (type == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve allowed source type for type id " + sourceTypeId);
|
||||
}
|
||||
if (type.isPublic() == isPublic)
|
||||
{
|
||||
allowedSourceTypes.add(type);
|
||||
}
|
||||
}
|
||||
for (CMISTypeId targetTypeId : allowedTargetTypeIds)
|
||||
{
|
||||
CMISTypeDefinition type = registry.objectDefsByTypeId.get(targetTypeId);
|
||||
if (type == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to retrieve allowed target type for type id " + targetTypeId);
|
||||
}
|
||||
if (type.isPublic() == isPublic)
|
||||
{
|
||||
allowedTargetTypes.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.CMISObjectTypeDefinition#resolveInheritance(org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry)
|
||||
*/
|
||||
@Override
|
||||
/*package*/ void resolveInheritance(DictionaryRegistry registry)
|
||||
{
|
||||
super.resolveInheritance(registry);
|
||||
inheritedAllowedSourceTypes.addAll(allowedSourceTypes);
|
||||
inheritedAllowedTargetTypes.addAll(allowedTargetTypes);
|
||||
if (internalParentType != null)
|
||||
{
|
||||
inheritedAllowedSourceTypes.addAll(internalParentType.getAllowedSourceTypes());
|
||||
inheritedAllowedTargetTypes.addAll(internalParentType.getAllowedTargetTypes());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For an association, get the collection of valid source types. For non-associations the collection will be empty.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedSourceTypes()
|
||||
{
|
||||
return inheritedAllowedSourceTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* For an association, get the collection of valid target types. For non-associations the collection will be empty.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Collection<CMISTypeDefinition> getAllowedTargetTypes()
|
||||
{
|
||||
return inheritedAllowedTargetTypes;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CMISRelationshipTypeDefinition[");
|
||||
builder.append("Id=").append(getTypeId().getId()).append(", ");
|
||||
builder.append("Namespace=").append(getTypeId().getLocalNamespace()).append(", ");
|
||||
builder.append("LocalName=").append(getTypeId().getLocalName()).append(", ");
|
||||
builder.append("QueryName=").append(getQueryName()).append(", ");
|
||||
builder.append("DisplayName=").append(getDisplayName()).append(", ");
|
||||
builder.append("ParentId=").append(getParentType() == null ? "<none>" : getParentType().getTypeId()).append(", ");
|
||||
builder.append("Description=").append(getDescription()).append(", ");
|
||||
builder.append("Creatable=").append(isCreatable()).append(", ");
|
||||
builder.append("Queryable=").append(isQueryable()).append(", ");
|
||||
builder.append("Controllable=").append(isControllablePolicy()).append(", ");
|
||||
builder.append("IncludedInSuperTypeQuery=").append(isIncludedInSuperTypeQuery()).append(", ");
|
||||
builder.append("AllowedSourceTypes=[");
|
||||
for (CMISTypeDefinition type : getAllowedSourceTypes())
|
||||
{
|
||||
builder.append(type.getTypeId()).append(",");
|
||||
}
|
||||
builder.append("], ");
|
||||
builder.append("AllowedTargetTypes=[");
|
||||
for (CMISTypeDefinition type : getAllowedTargetTypes())
|
||||
{
|
||||
builder.append(type.getTypeId()).append(",");
|
||||
}
|
||||
builder.append("], ");
|
||||
builder.append("SubTypes=").append(getSubTypes(false).size()).append(", ");
|
||||
builder.append("Properties=").append(getPropertyDefinitions().size());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.dictionary;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.mapping.CMISMapping;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Dictionary which provides Types that strictly conform to the CMIS specification.
|
||||
*
|
||||
* That is, only maps types to one of root Document, Folder, Relationship & Policy.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISStrictDictionaryService extends CMISAbstractDictionaryService
|
||||
{
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.dictionary.AbstractCMISDictionaryService#createDefinitions(org.alfresco.cmis.dictionary.AbstractCMISDictionaryService.DictionaryRegistry)
|
||||
*/
|
||||
@Override
|
||||
protected void createDefinitions(DictionaryRegistry registry)
|
||||
{
|
||||
createTypeDefs(registry, dictionaryService.getAllTypes());
|
||||
createAssocDefs(registry, dictionaryService.getAllAssociations());
|
||||
createTypeDefs(registry, dictionaryService.getAllAspects());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Type Definitions
|
||||
*
|
||||
* @param registry
|
||||
* @param classQNames
|
||||
*/
|
||||
private void createTypeDefs(DictionaryRegistry registry, Collection<QName> classQNames)
|
||||
{
|
||||
for (QName classQName : classQNames)
|
||||
{
|
||||
// skip items that are remapped to CMIS model
|
||||
if (cmisMapping.isRemappedType(classQName))
|
||||
continue;
|
||||
|
||||
// skip all items that are not mapped to CMIS model
|
||||
CMISTypeId typeId = cmisMapping.getCmisTypeId(classQName);
|
||||
if (typeId == null)
|
||||
continue;
|
||||
if (typeId.getScope() == CMISScope.RELATIONSHIP || typeId.getScope() == CMISScope.UNKNOWN )
|
||||
continue;
|
||||
|
||||
// create appropriate kind of type definition
|
||||
ClassDefinition classDef = dictionaryService.getClass(cmisMapping.getCmisType(typeId.getQName()));
|
||||
CMISAbstractTypeDefinition objectTypeDef = null;
|
||||
if (typeId.getScope() == CMISScope.DOCUMENT)
|
||||
{
|
||||
objectTypeDef = new CMISDocumentTypeDefinition(cmisMapping, typeId, dictionaryService, classDef);
|
||||
}
|
||||
else if (typeId.getScope() == CMISScope.FOLDER)
|
||||
{
|
||||
boolean isSystem = dictionaryService.isSubClass(classDef.getName(), ContentModel.TYPE_SYSTEM_FOLDER);
|
||||
objectTypeDef = new CMISFolderTypeDefinition(cmisMapping, typeId, dictionaryService, classDef, isSystem);
|
||||
}
|
||||
else if (typeId.getScope() == CMISScope.POLICY)
|
||||
{
|
||||
objectTypeDef = new CMISPolicyTypeDefinition(cmisMapping, typeId, dictionaryService, classDef);
|
||||
}
|
||||
else if (typeId.getScope() == CMISScope.OBJECT)
|
||||
{
|
||||
objectTypeDef = new CMISObjectTypeDefinition(cmisMapping, typeId, dictionaryService, classDef, false);
|
||||
}
|
||||
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Relationship Definitions
|
||||
*
|
||||
* @param registry
|
||||
* @param classQNames
|
||||
*/
|
||||
private void createAssocDefs(DictionaryRegistry registry, Collection<QName> classQNames)
|
||||
{
|
||||
CMISTypeId typeId = cmisMapping.getCmisTypeId(CMISScope.RELATIONSHIP, CMISMapping.RELATIONSHIP_QNAME);
|
||||
ClassDefinition classDef = dictionaryService.getClass(cmisMapping.getCmisType(typeId.getQName()));
|
||||
|
||||
// from Thor
|
||||
if (classDef == null)
|
||||
{
|
||||
if (classQNames.size() != 0)
|
||||
{
|
||||
logger.warn("Unexpected - no class for "+cmisMapping.getCmisType(typeId.getQName())+" - cannot create assocDefs for: "+classQNames);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CMISAbstractTypeDefinition objectTypeDef = new CMISRelationshipTypeDefinition(cmisMapping, typeId, dictionaryService, classDef, null);
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
|
||||
for (QName classQName : classQNames)
|
||||
{
|
||||
if (!cmisMapping.isValidCmisRelationship(classQName))
|
||||
continue;
|
||||
|
||||
// create appropriate kind of type definition
|
||||
typeId = cmisMapping.getCmisTypeId(CMISScope.RELATIONSHIP, classQName);
|
||||
AssociationDefinition assocDef = dictionaryService.getAssociation(classQName);
|
||||
objectTypeDef = new CMISRelationshipTypeDefinition(cmisMapping, typeId, dictionaryService, null, assocDef);
|
||||
|
||||
registry.registerTypeDefinition(objectTypeDef);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import org.alfresco.cmis.CMISActionEvaluator;
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* Base class for all action evaluators
|
||||
*
|
||||
* @author davidc
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractActionEvaluator <T> implements CMISActionEvaluator <T>
|
||||
{
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private CMISAllowedActionEnum action;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
* @param action
|
||||
*/
|
||||
protected AbstractActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return service registry
|
||||
*/
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.CMISActionEvaluator#getAction()
|
||||
*/
|
||||
public CMISAllowedActionEnum getAction()
|
||||
{
|
||||
return action;
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.alfresco.cmis.CMISPropertyAccessor;
|
||||
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneQueryParserExpressionAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Base class for all property accessors
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractProperty implements CMISPropertyAccessor, CMISPropertyLuceneBuilder
|
||||
{
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private String propertyName;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
* @param propertyName
|
||||
*/
|
||||
protected AbstractProperty(ServiceRegistry serviceRegistry, String propertyName)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return service registry
|
||||
*/
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.property.PropertyAccessor#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.property.PropertyAccessor#getMappedProperty()
|
||||
*/
|
||||
public QName getMappedProperty()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneIn(LuceneQueryParserAdaptor<Q, S, E> lqpa, Collection<Serializable> values, Boolean not,
|
||||
PredicateMode mode) throws E
|
||||
{
|
||||
LuceneQueryParserExpressionAdaptor<Q, E> expressionAdaptor = lqpa.getExpressionAdaptor();
|
||||
for(Serializable value : values)
|
||||
{
|
||||
expressionAdaptor.addOptional(buildLuceneEquality(lqpa, value, mode, LuceneFunction.FIELD));
|
||||
}
|
||||
if(not)
|
||||
{
|
||||
return expressionAdaptor.getNegatedQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return expressionAdaptor.getQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneInequality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return lqpa.getNegatedQuery(buildLuceneEquality(lqpa, value, mode, luceneFunction));
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode,
|
||||
LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLuceneFieldName()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setValue(NodeRef nodeRef, Serializable value)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.repo.search.adaptor.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Common support for lucene query building.
|
||||
*
|
||||
* @author andyh
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractSimpleProperty extends AbstractProperty
|
||||
{
|
||||
|
||||
protected AbstractSimpleProperty(ServiceRegistry serviceRegistry, String propertyName)
|
||||
{
|
||||
super(serviceRegistry, propertyName);
|
||||
}
|
||||
|
||||
protected abstract String getValueAsString(Serializable value);
|
||||
|
||||
protected String getRangeMax()
|
||||
{
|
||||
return "\uFFFF";
|
||||
}
|
||||
|
||||
protected String getRangeMin()
|
||||
{
|
||||
return "\u0000";
|
||||
}
|
||||
|
||||
protected abstract DataTypeDefinition getInDataType();
|
||||
|
||||
protected abstract QName getQNameForExists();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneEquality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return lqpa.getFieldQuery(getLuceneFieldName(), getValueAsString(value), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return lqpa.getFieldQuery("ISNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqpa.getFieldQuery("ISNOTNULL", getQNameForExists().toString(), AnalysisMode.DEFAULT, LuceneFunction.FIELD);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqpa.getRangeQuery(field, stringValue, getRangeMax(), false, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqpa.getRangeQuery(field, stringValue, getRangeMax(), true, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThan(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqpa.getRangeQuery(field, getRangeMin(), stringValue, true, false, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, org.alfresco.repo.search.impl.querymodel.PredicateMode)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
return lqpa.getRangeQuery(field, getRangeMin(), stringValue, true, true, AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean)
|
||||
*/
|
||||
public <Q, S, E extends Throwable> Q buildLuceneLike(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, Boolean not) throws E
|
||||
{
|
||||
String field = getLuceneFieldName();
|
||||
String stringValue = getValueAsString(value);
|
||||
|
||||
Q q = lqpa.getLikeQuery(field, stringValue, AnalysisMode.IDENTIFIER);
|
||||
if (not)
|
||||
{
|
||||
q = lqpa.getNegatedQuery(q);
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField()
|
||||
*/
|
||||
public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E
|
||||
{
|
||||
return getLuceneFieldName();
|
||||
}
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.version.VersionBaseModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Base class for versioning property accessors.
|
||||
*
|
||||
* @author dward
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractVersioningProperty extends AbstractProperty
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
protected AbstractVersioningProperty(ServiceRegistry serviceRegistry, String propertyName)
|
||||
{
|
||||
super(serviceRegistry, propertyName);
|
||||
}
|
||||
|
||||
public NodeRef getVersionSeries(NodeRef nodeRef)
|
||||
{
|
||||
if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL))
|
||||
{
|
||||
// Due to the remapping done for us by the versioned node services, we can simply look up the properties
|
||||
// containing the component parts of the node ref to map back to the original node
|
||||
Map<QName, Serializable> properties = getServiceRegistry().getNodeService().getProperties(nodeRef);
|
||||
nodeRef = new NodeRef((String) properties.get(ContentModel.PROP_STORE_PROTOCOL),
|
||||
(String) properties.get(ContentModel.PROP_STORE_IDENTIFIER), (String) properties
|
||||
.get(ContentModel.PROP_NODE_UUID));
|
||||
}
|
||||
else if (isWorkingCopy(nodeRef))
|
||||
{
|
||||
NodeRef originalNodeRef = getServiceRegistry().getCopyService().getOriginal(nodeRef);
|
||||
nodeRef = originalNodeRef == null ? nodeRef : originalNodeRef;
|
||||
}
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public boolean isWorkingCopy(NodeRef nodeRef)
|
||||
{
|
||||
return getServiceRegistry().getCheckOutCheckInService().isWorkingCopy(nodeRef);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isImmutable(NodeRef nodeRef)
|
||||
{
|
||||
return getServiceRegistry().getLockService().getLockType(nodeRef) == LockType.READ_ONLY_LOCK;
|
||||
}
|
||||
|
||||
public boolean hasWorkingCopy(NodeRef nodeRef)
|
||||
{
|
||||
return isImmutable(nodeRef) && getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(nodeRef) != null;
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.chemistry.abdera.ext.CMISAllowableActions;
|
||||
|
||||
/**
|
||||
* This evaluator determines an action availability in accordance with collection of aspects and rules of checking application of the aspects. The rules are:<br />
|
||||
* - is it expected that aspect(s) had been applied;<br />
|
||||
* - should all aspects in the collection satisfying to the specified condition or at least 1 aspect is enough<br />
|
||||
* <br />
|
||||
* This evaluator is generic, because it is used in the scope of {@link CompositeActionEvaluator}
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class AspectActionEvaluator<ObjectType> extends AbstractActionEvaluator<ObjectType>
|
||||
{
|
||||
private NodeService nodeService;
|
||||
|
||||
private boolean expected;
|
||||
|
||||
private boolean allAspectsMustConcur;
|
||||
|
||||
private boolean defaultAllowing;
|
||||
|
||||
private QName[] aspects;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param serviceRegistry - {@link ServiceRegistry} instance
|
||||
* @param action - {@link CMISAllowableActions} enumeration value, which determines the action to check
|
||||
* @param expected - {@link Boolean} value, which determines: <code>true</code> - aspects application is expected, <code>false</code> - aspects absence is expected
|
||||
* @param allAspectsMustConcur - {@link Boolean} value, which determines: <code>true</code> - all aspects should satisfy <code>expected</code> condition, <code>false</code> -
|
||||
* at least 1 aspect should satisfy the <code>expected</code> condition
|
||||
* @param defaultAllowing - {@link Boolean} value, which determines availability of action for several special cases (invalid object id, empty collection of the aspects etc.)
|
||||
* @param aspects {@link QName}... collection, which specifies all aspects, required for validation
|
||||
*/
|
||||
public AspectActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, boolean expected, boolean allAspectsMustConcur, boolean defaultAllowing,
|
||||
QName... aspects)
|
||||
{
|
||||
super(serviceRegistry, action);
|
||||
this.expected = expected;
|
||||
this.allAspectsMustConcur = allAspectsMustConcur;
|
||||
this.aspects = aspects;
|
||||
|
||||
nodeService = serviceRegistry.getNodeService();
|
||||
}
|
||||
|
||||
public boolean isAllowed(ObjectType id)
|
||||
{
|
||||
NodeRef nodeRef = (id instanceof NodeRef) ? ((NodeRef) id) : (null);
|
||||
|
||||
if ((null != nodeRef) && (null != aspects))
|
||||
{
|
||||
for (QName aspectId : aspects)
|
||||
{
|
||||
boolean aspect = nodeService.hasAspect(nodeRef, aspectId);
|
||||
|
||||
if (!expected)
|
||||
{
|
||||
aspect = !aspect;
|
||||
}
|
||||
|
||||
if (!allAspectsMustConcur && aspect)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (allAspectsMustConcur && !aspect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allAspectsMustConcur;
|
||||
}
|
||||
|
||||
return defaultAllowing;
|
||||
}
|
||||
}
|
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISQueryException;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.search.adaptor.lucene.AnalysisMode;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneFunction;
|
||||
import org.alfresco.repo.search.adaptor.lucene.LuceneQueryParserAdaptor;
|
||||
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Get the CMIS object type id property
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class BaseTypeIdProperty extends AbstractProperty
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public BaseTypeIdProperty(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
super(serviceRegistry, CMISDictionaryModel.PROP_BASE_TYPE_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
{
|
||||
QName type = getServiceRegistry().getNodeService().getType(nodeRef);
|
||||
return getServiceRegistry().getCMISDictionaryService().findTypeForClass(type).getBaseType().getTypeId().getId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
|
||||
*/
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
QName type = assocRef.getTypeQName();
|
||||
return getServiceRegistry().getCMISDictionaryService().findTypeForClass(type, CMISScope.RELATIONSHIP).getBaseType().getTypeId().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Q, S, E extends Throwable> Q buildLuceneEquality(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E
|
||||
{
|
||||
return lqpa.getFieldQuery("TYPE", getBaseType(getValueAsString(value)), AnalysisMode.IDENTIFIER, luceneFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Q, S, E extends Throwable> Q buildLuceneExists(LuceneQueryParserAdaptor<Q, S, E> lqpa, Boolean not) throws E
|
||||
{
|
||||
if (not)
|
||||
{
|
||||
return lqpa.getMatchNoneQuery();
|
||||
}
|
||||
else
|
||||
{
|
||||
return lqpa.getMatchAllQuery();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getBaseType(String tableName)
|
||||
{
|
||||
CMISTypeDefinition typeDef = getServiceRegistry().getCMISDictionaryService().findTypeByQueryName(tableName);
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw new CMISQueryException("Unknwon base type: " + tableName);
|
||||
}
|
||||
if(!typeDef.getBaseType().equals(typeDef))
|
||||
{
|
||||
throw new CMISQueryException("Not a base type: " + tableName);
|
||||
}
|
||||
if(!typeDef.isQueryable())
|
||||
{
|
||||
throw new CMISQueryException("Base type is not queryable: " + tableName);
|
||||
}
|
||||
return typeDef.getTypeId().getQName().toString();
|
||||
}
|
||||
|
||||
private String getValueAsString(Serializable value)
|
||||
{
|
||||
String asString = DefaultTypeConverter.INSTANCE.convert(String.class, value);
|
||||
return asString;
|
||||
}
|
||||
}
|
@@ -1,982 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlService;
|
||||
import org.alfresco.cmis.CMISActionEvaluator;
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISPropertyId;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.cmis.CMISTypeId;
|
||||
import org.alfresco.cmis.mapping.ParentTypeActionEvaluator.ParentTypeEnum;
|
||||
import org.alfresco.cmis.mapping.PropertyActionEvaluator.PropertyDescriptor;
|
||||
import org.alfresco.cmis.mapping.TypeAttributeActionEvaluator.TypeDefinitionAttributeEnum;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.opencmis.CMISAccessControlFormatEnum;
|
||||
import org.alfresco.repo.version.Version2Model;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS <-> Alfresco mappings
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class CMISMapping implements InitializingBean
|
||||
{
|
||||
private static final Comparable<Object> CONTENT_STREAM_SUPPORTED_COMPARATOR = new Comparable<Object>()
|
||||
{
|
||||
@Override
|
||||
public int compareTo(Object another)
|
||||
{
|
||||
CMISContentStreamAllowedEnum converted = (CMISContentStreamAllowedEnum) another;
|
||||
return (CMISContentStreamAllowedEnum.NOT_ALLOWED != converted) ? (0) : (-1);
|
||||
}
|
||||
};
|
||||
|
||||
private static final PropertyDescriptor PROPERTY_STREAM_ID = new PropertyDescriptor(CMISDictionaryModel.PROP_CONTENT_STREAM_ID, null, false);
|
||||
|
||||
private static final boolean DEFAULT_ALLOWING = false;
|
||||
|
||||
private static final PropertyDescriptor PROPERTY_MUTABLE = new PropertyDescriptor(CMISDictionaryModel.PROP_IS_IMMUTABLE, false, true);
|
||||
|
||||
// Logger
|
||||
protected static final Log logger = LogFactory.getLog(CMISMapping.class);
|
||||
|
||||
/**
|
||||
* The Alfresco CMIS Namespace
|
||||
*/
|
||||
public static String CMIS_MODEL_NS = "cmis";
|
||||
public static String CMIS_MODEL_URI = "http://www.alfresco.org/model/cmis/1.0/cs01";
|
||||
|
||||
public static String CMIS_EXT_NS = "cmisext";
|
||||
public static String CMIS_EXT_URI = "http://www.alfresco.org/model/cmis/1.0/cs01ext";
|
||||
|
||||
/**
|
||||
* The Alfresco CMIS Model name.
|
||||
*/
|
||||
public static String CMIS_MODEL_NAME = "cmismodel";
|
||||
|
||||
/**
|
||||
* The QName for the Alfresco CMIS Model.
|
||||
*/
|
||||
public static QName CMIS_MODEL_QNAME = QName.createQName(CMIS_MODEL_URI, CMIS_MODEL_NAME);
|
||||
|
||||
// CMIS Data Types
|
||||
public static QName CMIS_DATATYPE_ID = QName.createQName(CMIS_MODEL_URI, "id");
|
||||
public static QName CMIS_DATATYPE_URI = QName.createQName(CMIS_MODEL_URI, "uri");
|
||||
public static QName CMIS_DATATYPE_XML = QName.createQName(CMIS_MODEL_URI, "xml");
|
||||
public static QName CMIS_DATATYPE_HTML = QName.createQName(CMIS_MODEL_URI, "html");
|
||||
|
||||
// CMIS Types
|
||||
public static QName OBJECT_QNAME = QName.createQName(CMIS_EXT_URI, "object");
|
||||
public static QName FILESYSTEM_OBJECT_QNAME = QName.createQName(CMIS_MODEL_URI, "filesystemobject");
|
||||
public static QName DOCUMENT_QNAME = QName.createQName(CMIS_MODEL_URI, "document");
|
||||
public static QName FOLDER_QNAME = QName.createQName(CMIS_MODEL_URI, "folder");
|
||||
public static QName RELATIONSHIP_QNAME = QName.createQName(CMIS_MODEL_URI, "relationship");
|
||||
public static QName POLICY_QNAME = QName.createQName(CMIS_MODEL_URI, "policy");
|
||||
|
||||
// CMIS Internal Type Ids
|
||||
public static CMISTypeId OBJECT_TYPE_ID = new CMISTypeId(CMISScope.OBJECT, OBJECT_QNAME, CMIS_MODEL_NS + ":" + OBJECT_QNAME.getLocalName(), OBJECT_QNAME);
|
||||
public static CMISTypeId FILESYSTEM_OBJECT_TYPE_ID = new CMISTypeId(CMISScope.OBJECT, FILESYSTEM_OBJECT_QNAME, CMIS_MODEL_NS + ":" + FILESYSTEM_OBJECT_QNAME.getLocalName(), FILESYSTEM_OBJECT_QNAME);
|
||||
|
||||
// Service Dependencies
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private CMISServices cmisService;
|
||||
|
||||
// Mappings
|
||||
private Map<QName, CMISTypeId> mapAlfrescoQNameToTypeId = new HashMap<QName, CMISTypeId>();
|
||||
private Map<QName, QName> mapCmisQNameToAlfrescoQName = new HashMap<QName, QName>();
|
||||
private Map<QName, QName> mapAlfrescoQNameToCmisQName = new HashMap<QName, QName>();
|
||||
private Map<QName, CMISDataTypeEnum> mapAlfrescoToCmisDataType = new HashMap<QName, CMISDataTypeEnum>();
|
||||
private Map<String, AbstractProperty> propertyAccessors = new HashMap<String, AbstractProperty>();
|
||||
private Map<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>>> actionEvaluators = new HashMap<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>>>();
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
//
|
||||
// Type Mappings
|
||||
//
|
||||
|
||||
mapAlfrescoQNameToTypeId.put(OBJECT_QNAME, OBJECT_TYPE_ID);
|
||||
mapAlfrescoQNameToTypeId.put(FILESYSTEM_OBJECT_QNAME, FILESYSTEM_OBJECT_TYPE_ID);
|
||||
mapAlfrescoQNameToTypeId.put(DOCUMENT_QNAME, CMISDictionaryModel.DOCUMENT_TYPE_ID);
|
||||
mapAlfrescoQNameToTypeId.put(FOLDER_QNAME, CMISDictionaryModel.FOLDER_TYPE_ID);
|
||||
mapAlfrescoQNameToTypeId.put(RELATIONSHIP_QNAME, CMISDictionaryModel.RELATIONSHIP_TYPE_ID);
|
||||
mapAlfrescoQNameToTypeId.put(POLICY_QNAME, CMISDictionaryModel.POLICY_TYPE_ID);
|
||||
|
||||
mapAlfrescoQNameToCmisQName.put(ContentModel.TYPE_CONTENT, DOCUMENT_QNAME);
|
||||
mapAlfrescoQNameToCmisQName.put(ContentModel.TYPE_FOLDER, FOLDER_QNAME);
|
||||
|
||||
mapCmisQNameToAlfrescoQName.put(DOCUMENT_QNAME, ContentModel.TYPE_CONTENT);
|
||||
mapCmisQNameToAlfrescoQName.put(FOLDER_QNAME, ContentModel.TYPE_FOLDER);
|
||||
mapCmisQNameToAlfrescoQName.put(RELATIONSHIP_QNAME, null);
|
||||
mapCmisQNameToAlfrescoQName.put(POLICY_QNAME, null);
|
||||
|
||||
//
|
||||
// Data Type Mappings
|
||||
//
|
||||
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.ANY, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.ENCRYPTED, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.ASSOC_REF, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.BOOLEAN, CMISDataTypeEnum.BOOLEAN);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.CATEGORY, CMISDataTypeEnum.ID);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.CHILD_ASSOC_REF, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.CONTENT, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.DATE, CMISDataTypeEnum.DATETIME);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.DATETIME, CMISDataTypeEnum.DATETIME);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.DOUBLE, CMISDataTypeEnum.DECIMAL);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.FLOAT, CMISDataTypeEnum.DECIMAL);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.INT, CMISDataTypeEnum.INTEGER);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.LOCALE, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.PERIOD, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.LONG, CMISDataTypeEnum.INTEGER);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.MLTEXT, CMISDataTypeEnum.STRING);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.NODE_REF, CMISDataTypeEnum.ID);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.PATH, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.QNAME, null);
|
||||
mapAlfrescoToCmisDataType.put(DataTypeDefinition.TEXT, CMISDataTypeEnum.STRING);
|
||||
mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_ID, CMISDataTypeEnum.ID);
|
||||
mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_URI, CMISDataTypeEnum.URI);
|
||||
mapAlfrescoToCmisDataType.put(CMIS_DATATYPE_HTML, CMISDataTypeEnum.HTML);
|
||||
|
||||
//
|
||||
// Property Mappings
|
||||
//
|
||||
|
||||
registerPropertyAccessor(new ObjectIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new ObjectTypeIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new BaseTypeIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_CREATED_BY, ContentModel.PROP_CREATOR));
|
||||
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_CREATION_DATE, ContentModel.PROP_CREATED));
|
||||
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_LAST_MODIFIED_BY, ContentModel.PROP_MODIFIER));
|
||||
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE, ContentModel.PROP_MODIFIED));
|
||||
registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_CHANGE_TOKEN, null));
|
||||
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_NAME,
|
||||
ContentModel.PROP_NAME)
|
||||
{
|
||||
@Override
|
||||
public Serializable getValue(AssociationRef assocRef)
|
||||
{
|
||||
// Let's use the association ref as the name
|
||||
return assocRef.toString();
|
||||
}
|
||||
});
|
||||
registerPropertyAccessor(new IsImmutableProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new IsLatestVersionProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new IsMajorVersionProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new IsLatestMajorVersionProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new VersionLabelProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new VersionSeriesIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new IsVersionSeriesCheckedOutProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new VersionSeriesCheckedOutByProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new VersionSeriesCheckedOutIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new CheckinCommentProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new ContentStreamLengthProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new ContentStreamMimetypeProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new ContentStreamIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME, ContentModel.PROP_NAME));
|
||||
registerPropertyAccessor(new ParentProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new PathProperty(serviceRegistry, cmisService));
|
||||
registerPropertyAccessor(new FixedValueProperty(serviceRegistry, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS, null));
|
||||
registerPropertyAccessor(new SourceIdProperty(serviceRegistry));
|
||||
registerPropertyAccessor(new TargetIdProperty(serviceRegistry));
|
||||
|
||||
//
|
||||
// Action Evaluator Mappings
|
||||
//
|
||||
|
||||
// NOTE: The order of evaluators is important - they must be in the order as specified in CMIS-Core.xsd
|
||||
// so that schema validation passes
|
||||
|
||||
// Depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT).addPermissionCondition(
|
||||
PermissionService.DELETE_NODE).addPropertyCondition(PROPERTY_MUTABLE));
|
||||
// Depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES).addPermissionCondition(
|
||||
PermissionService.WRITE_PROPERTIES).addAspectCondition(false, Version2Model.ASPECT_VERSION).addPropertyCondition(PROPERTY_MUTABLE));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_PROPERTIES));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_ASSOCIATIONS));
|
||||
|
||||
registerEvaluator(CMISScope.DOCUMENT, new ParentActionEvaluator(new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS,
|
||||
DEFAULT_ALLOWING, PermissionService.READ_PERMISSIONS)));
|
||||
|
||||
// Is CAN_MOVE correct mapping?
|
||||
|
||||
// Depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT).addPermissionCondition(
|
||||
PermissionService.DELETE_NODE).addAspectCondition(false, Version2Model.ASPECT_VERSION).addPropertyCondition(PROPERTY_MUTABLE));
|
||||
|
||||
// Depends on cmis:immutable
|
||||
// Also depends on content stream appearance definition in the model and whether stream is set...
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_CONTENT_STREAM)
|
||||
.addPermissionCondition(PermissionService.WRITE_CONTENT).addPropertyCondition(PROPERTY_MUTABLE, PROPERTY_STREAM_ID).addAspectCondition(false,
|
||||
Version2Model.ASPECT_VERSION).addTypeAttributeCondition(TypeDefinitionAttributeEnum.CONTENT_STREAM_ALLOWED, new Comparable<Object>()
|
||||
{
|
||||
@Override
|
||||
public int compareTo(Object another)
|
||||
{
|
||||
return CMISContentStreamAllowedEnum.ALLOWED.compareTo((CMISContentStreamAllowedEnum) another);
|
||||
}
|
||||
}));
|
||||
|
||||
// Also depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_CHECKOUT).addPermissionCondition(
|
||||
PermissionService.CHECK_OUT).addPropertyCondition(PROPERTY_MUTABLE).addLockCondition(LockType.READ_ONLY_LOCK).addPwcCondition(false));
|
||||
|
||||
// Same as check-in. It requires check if specified object is a PWC
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_CANCEL_CHECKOUT).addPermissionCondition(
|
||||
PermissionService.CANCEL_CHECK_OUT).addPwcCondition(true));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_CHECKIN).addPermissionCondition(
|
||||
PermissionService.CHECK_IN).addPwcCondition(true));
|
||||
// Also depends on model definition... also depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_SET_CONTENT_STREAM)
|
||||
.addPermissionCondition(PermissionService.WRITE_CONTENT).addAspectCondition(false, Version2Model.ASPECT_VERSION).addPropertyCondition(PROPERTY_MUTABLE)
|
||||
.addTypeAttributeCondition(TypeDefinitionAttributeEnum.CONTENT_STREAM_ALLOWED, CONTENT_STREAM_SUPPORTED_COMPARATOR));
|
||||
|
||||
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ALL_VERSIONS, true));
|
||||
// Depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_ADD_OBJECT_TO_FOLDER)
|
||||
.addPropertyCondition(PROPERTY_MUTABLE).addPermissionCondition(PermissionService.CREATE_ASSOCIATIONS));
|
||||
// Is CAN_REMOVE_FROM_FOLDER correct mapping?
|
||||
// Should be aware about amount of parents. It is not allowed for PRIMARY parent!
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER)
|
||||
.addPermissionCondition(PermissionService.DELETE_ASSOCIATIONS).addPropertyCondition(PROPERTY_MUTABLE).addParentTypeCondition(ParentTypeEnum.MULTI_FILED));
|
||||
// Depends on availability of the stream (including streams of renditions)
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_GET_CONTENT_STREAM)
|
||||
.addPermissionCondition(PermissionService.READ_CONTENT).addPropertyCondition(PROPERTY_STREAM_ID).addTypeAttributeCondition(
|
||||
TypeDefinitionAttributeEnum.CONTENT_STREAM_ALLOWED, CONTENT_STREAM_SUPPORTED_COMPARATOR));
|
||||
|
||||
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, true));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false));
|
||||
// Depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_RELATIONSHIP)
|
||||
.addPermissionCondition(PermissionService.CREATE_ASSOCIATIONS).addPropertyCondition(PROPERTY_MUTABLE));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RENDITIONS, true));
|
||||
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_PERMISSIONS));
|
||||
// Depends on cmis:immutable
|
||||
registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL).addPermissionCondition(
|
||||
PermissionService.CHANGE_PERMISSIONS).addPropertyCondition(PROPERTY_MUTABLE));
|
||||
|
||||
registerEvaluator(CMISScope.FOLDER, new RootActionEvaluator<NodeRef>(new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT,
|
||||
DEFAULT_ALLOWING, PermissionService.DELETE_NODE), false));
|
||||
registerEvaluator(CMISScope.FOLDER, new CompositeActionEvaluator<NodeRef>(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES)
|
||||
.addPermissionCondition(PermissionService.WRITE_PROPERTIES));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_TREE, DEFAULT_ALLOWING, PermissionService.READ_CHILDREN));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, DEFAULT_ALLOWING, PermissionService.READ_PROPERTIES));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_ASSOCIATIONS));
|
||||
registerEvaluator(CMISScope.FOLDER, new ParentActionEvaluator(new PermissionActionEvaluator<NodeRef>(serviceRegistry,
|
||||
CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, DEFAULT_ALLOWING, PermissionService.READ_PERMISSIONS)));
|
||||
registerEvaluator(CMISScope.FOLDER, new ParentActionEvaluator(new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_PARENT,
|
||||
DEFAULT_ALLOWING, PermissionService.READ_PERMISSIONS)));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_DESCENDANTS, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_CHILDREN));
|
||||
// Is CAN_MOVE_OBJECT correct mapping?
|
||||
registerEvaluator(CMISScope.FOLDER, new RootActionEvaluator<NodeRef>(new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT,
|
||||
DEFAULT_ALLOWING, PermissionService.DELETE_NODE), false));
|
||||
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false));
|
||||
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, true));
|
||||
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_CHILDREN, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_CHILDREN));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_DOCUMENT, DEFAULT_ALLOWING,
|
||||
PermissionService.CREATE_CHILDREN));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_FOLDER, DEFAULT_ALLOWING,
|
||||
PermissionService.CREATE_CHILDREN));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_RELATIONSHIP, DEFAULT_ALLOWING,
|
||||
PermissionService.CREATE_ASSOCIATIONS));
|
||||
registerEvaluator(CMISScope.FOLDER, new RootActionEvaluator<NodeRef>(new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_TREE,
|
||||
DEFAULT_ALLOWING, PermissionService.DELETE_NODE), false));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, DEFAULT_ALLOWING,
|
||||
PermissionService.READ_PERMISSIONS));
|
||||
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator<Object>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, DEFAULT_ALLOWING,
|
||||
PermissionService.CHANGE_PERMISSIONS));
|
||||
|
||||
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, true));
|
||||
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
|
||||
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, true));
|
||||
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false));
|
||||
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false));
|
||||
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_ADD_OBJECT_TO_FOLDER, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false));
|
||||
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
||||
public void setCMISService(CMISServices cmisService)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return namespaceService
|
||||
*/
|
||||
/*package*/ NamespaceService getNamespaceService()
|
||||
{
|
||||
return serviceRegistry.getNamespaceService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CMIS Type Id given the serialized type Id
|
||||
*
|
||||
* @param typeId type id in the form of <ROOT_TYPE_ID>/<PREFIX>_<LOCALNAME>
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeId getCmisTypeId(String typeId)
|
||||
{
|
||||
// Is it a CMIS root object type id?
|
||||
if (typeId.equalsIgnoreCase(CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()))
|
||||
{
|
||||
return CMISDictionaryModel.DOCUMENT_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(CMISDictionaryModel.FOLDER_TYPE_ID.getId()))
|
||||
{
|
||||
return CMISDictionaryModel.FOLDER_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(CMISDictionaryModel.RELATIONSHIP_TYPE_ID.getId()))
|
||||
{
|
||||
return CMISDictionaryModel.RELATIONSHIP_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(CMISDictionaryModel.POLICY_TYPE_ID.getId()))
|
||||
{
|
||||
return CMISDictionaryModel.POLICY_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(OBJECT_TYPE_ID.getId()))
|
||||
{
|
||||
return OBJECT_TYPE_ID;
|
||||
}
|
||||
else if (typeId.equalsIgnoreCase(FILESYSTEM_OBJECT_TYPE_ID.getId()))
|
||||
{
|
||||
return FILESYSTEM_OBJECT_TYPE_ID;
|
||||
}
|
||||
|
||||
// Is it an Alfresco type id?
|
||||
if (typeId.length() < 4 || typeId.charAt(1) != ':')
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Malformed type id '" + typeId + "'");
|
||||
}
|
||||
|
||||
// Alfresco type id
|
||||
CMISScope scope = (CMISScope)CMISScope.FACTORY.fromLabel(typeId.substring(0, 1));
|
||||
if (scope == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Malformed type id '" + typeId + "'; discriminator " + typeId.charAt(0) + " unknown");
|
||||
}
|
||||
QName typeQName = QName.createQName(typeId.substring(2), serviceRegistry.getNamespaceService());
|
||||
|
||||
// Construct CMIS Type Id
|
||||
return new CMISTypeId(scope, typeQName, typeId, typeQName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CMIS Type Id given the Alfresco QName for the type in any Alfresco model
|
||||
*
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public CMISTypeId getCmisTypeId(CMISScope scope, QName typeQName)
|
||||
{
|
||||
CMISTypeId typeId = mapAlfrescoQNameToTypeId.get(typeQName);
|
||||
if (typeId == null)
|
||||
{
|
||||
String typeIdStr = scope.getLabel() + ":" + typeQName.toPrefixString(serviceRegistry.getNamespaceService());
|
||||
return new CMISTypeId(scope, typeQName, typeIdStr, typeQName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return typeId;
|
||||
}
|
||||
}
|
||||
|
||||
public CMISTypeId getCmisTypeId(QName classQName)
|
||||
{
|
||||
if (classQName.equals(ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.DOCUMENT, classQName);
|
||||
}
|
||||
if (classQName.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.FOLDER, classQName);
|
||||
}
|
||||
if (classQName.equals(CMISMapping.RELATIONSHIP_QNAME))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.RELATIONSHIP, classQName);
|
||||
}
|
||||
if (classQName.equals(CMISMapping.POLICY_QNAME))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.POLICY, classQName);
|
||||
}
|
||||
if (classQName.equals(CMISMapping.OBJECT_QNAME))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.OBJECT, classQName);
|
||||
}
|
||||
if (classQName.equals(CMISMapping.FILESYSTEM_OBJECT_QNAME))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.OBJECT, classQName);
|
||||
}
|
||||
if (isValidCmisDocument(classQName))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.DOCUMENT, classQName);
|
||||
}
|
||||
if (isValidCmisFolder(classQName))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.FOLDER, classQName);
|
||||
}
|
||||
if (isValidCmisPolicy(classQName))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.POLICY, classQName);
|
||||
}
|
||||
if (isValidCmisRelationship(classQName))
|
||||
{
|
||||
return getCmisTypeId(CMISScope.RELATIONSHIP, classQName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String buildPrefixEncodedString(QName qname)
|
||||
{
|
||||
return qname.toPrefixString(serviceRegistry.getNamespaceService());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a valid cmis document or folder type (not a relationship)
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidCmisDocumentOrFolder(QName typeQName)
|
||||
{
|
||||
return isValidCmisFolder(typeQName) || isValidCmisDocument(typeQName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a valid CMIS folder type?
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidCmisFolder(QName typeQName)
|
||||
{
|
||||
if (typeQName == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (typeQName.equals(FOLDER_QNAME))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (serviceRegistry.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
if (typeQName.equals(ContentModel.TYPE_FOLDER))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a valid CMIS document type?
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidCmisDocument(QName typeQName)
|
||||
{
|
||||
if (typeQName == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (typeQName.equals(DOCUMENT_QNAME))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (serviceRegistry.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
if (typeQName.equals(ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a valid CMIS policy type?
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidCmisPolicy(QName typeQName)
|
||||
{
|
||||
if (typeQName == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (typeQName.equals(POLICY_QNAME))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AspectDefinition aspectDef = serviceRegistry.getDictionaryService().getAspect(typeQName);
|
||||
if (aspectDef == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aspectDef.getName().equals(ContentModel.ASPECT_VERSIONABLE) ||
|
||||
aspectDef.getName().equals(ContentModel.ASPECT_AUDITABLE) ||
|
||||
aspectDef.getName().equals(ContentModel.ASPECT_REFERENCEABLE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is an association valid in CMIS? It must be a non-child relationship and the source and target must both be valid
|
||||
* CMIS types.
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param associationQName
|
||||
* @return
|
||||
*/
|
||||
public boolean isValidCmisRelationship(QName associationQName)
|
||||
{
|
||||
if (associationQName == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (associationQName.equals(RELATIONSHIP_QNAME))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
AssociationDefinition associationDefinition = serviceRegistry.getDictionaryService().getAssociation(associationQName);
|
||||
if (associationDefinition == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (associationDefinition.isChild())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an Alfresco model type map it to the appropriate type. Maps cm:folder and cm:content to the CMIS
|
||||
* definitions
|
||||
*
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public QName getCmisType(QName typeQName)
|
||||
{
|
||||
QName mapped = mapAlfrescoQNameToCmisQName.get(typeQName);
|
||||
if (mapped != null)
|
||||
{
|
||||
return mapped;
|
||||
}
|
||||
return typeQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Alfresco Type mapped to an alternative CMIS Type?
|
||||
*
|
||||
* @param typeQName
|
||||
* @return
|
||||
*/
|
||||
public boolean isRemappedType(QName typeQName)
|
||||
{
|
||||
return mapAlfrescoQNameToCmisQName.containsKey(typeQName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a CMIS model type map it to the appropriate Alfresco type.
|
||||
*
|
||||
* @param cmisTypeQName
|
||||
* @return
|
||||
*/
|
||||
public QName getAlfrescoType(QName cmisTypeQName)
|
||||
{
|
||||
QName mapped = mapCmisQNameToAlfrescoQName.get(cmisTypeQName);
|
||||
if (mapped != null)
|
||||
{
|
||||
return mapped;
|
||||
}
|
||||
return cmisTypeQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CMIS property type for a property
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param propertyQName
|
||||
* @return
|
||||
*/
|
||||
public CMISDataTypeEnum getDataType(DataTypeDefinition datatype)
|
||||
{
|
||||
return getDataType(datatype.getName());
|
||||
}
|
||||
|
||||
public CMISDataTypeEnum getDataType(QName dataType)
|
||||
{
|
||||
return mapAlfrescoToCmisDataType.get(dataType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup a CMIS property name and get the Alfresco property QName
|
||||
*
|
||||
* @param dictionaryService
|
||||
* @param namespaceService
|
||||
* @param cmisPropertyName
|
||||
* @return
|
||||
*/
|
||||
public QName getPropertyQName(String cmisPropertyName)
|
||||
{
|
||||
// Try the cmis model first - it it matches we are done
|
||||
QName cmisPropertyQName = QName.createQName(CMIS_MODEL_URI, cmisPropertyName);
|
||||
if (serviceRegistry.getDictionaryService().getProperty(cmisPropertyQName) != null)
|
||||
{
|
||||
return cmisPropertyQName;
|
||||
}
|
||||
|
||||
// Find prefix and property name - in upper case
|
||||
|
||||
int split = cmisPropertyName.indexOf('_');
|
||||
|
||||
// CMIS case insensitive hunt - no prefix
|
||||
if (split == -1)
|
||||
{
|
||||
for (QName qname : serviceRegistry.getDictionaryService().getAllProperties(null))
|
||||
{
|
||||
if (qname.getNamespaceURI().equals(CMIS_MODEL_URI))
|
||||
{
|
||||
if (qname.getLocalName().equalsIgnoreCase(cmisPropertyName))
|
||||
{
|
||||
return qname;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String prefix = cmisPropertyName.substring(0, split);
|
||||
String localName = cmisPropertyName.substring(split + 1);
|
||||
|
||||
// Try lower case version first.
|
||||
|
||||
QName propertyQName = QName.createQName(prefix.toLowerCase(), localName.toLowerCase(), serviceRegistry.getNamespaceService());
|
||||
if (serviceRegistry.getDictionaryService().getProperty(propertyQName) != null)
|
||||
{
|
||||
return propertyQName;
|
||||
}
|
||||
|
||||
// Full case insensitive hunt
|
||||
|
||||
for (String test : serviceRegistry.getNamespaceService().getPrefixes())
|
||||
{
|
||||
if (test.equalsIgnoreCase(prefix))
|
||||
{
|
||||
prefix = test;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String uri = serviceRegistry.getNamespaceService().getNamespaceURI(prefix);
|
||||
|
||||
for (QName qname : serviceRegistry.getDictionaryService().getAllProperties(null))
|
||||
{
|
||||
if (qname.getNamespaceURI().equals(uri))
|
||||
{
|
||||
if (qname.getLocalName().equalsIgnoreCase(localName))
|
||||
{
|
||||
return qname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
* @param propertyQName
|
||||
* @return
|
||||
*/
|
||||
public String getCmisPropertyId(QName propertyQName)
|
||||
{
|
||||
return propertyQName.toPrefixString(serviceRegistry.getNamespaceService());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Property Accessor
|
||||
*
|
||||
* @param propertyId
|
||||
* @return
|
||||
*/
|
||||
public AbstractProperty getPropertyAccessor(CMISPropertyId propertyId)
|
||||
{
|
||||
AbstractProperty propertyAccessor = propertyAccessors.get(propertyId.getId());
|
||||
if (propertyAccessor == null)
|
||||
{
|
||||
QName propertyQName = propertyId.getQName();
|
||||
if (propertyQName == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can't get property accessor for property id " + propertyId.getId() + " due to unknown property QName");
|
||||
}
|
||||
propertyAccessor = new DirectProperty(serviceRegistry, propertyId.getId(), propertyQName);
|
||||
}
|
||||
return propertyAccessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register pre-defined Property Accessor
|
||||
*
|
||||
* @param propertyAccessor
|
||||
*/
|
||||
private void registerPropertyAccessor(AbstractProperty propertyAccessor)
|
||||
{
|
||||
propertyAccessors.put(propertyAccessor.getName(), propertyAccessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Action Evaluators applicable for the given CMIS Scope
|
||||
*
|
||||
* @param cmisScope
|
||||
* @return
|
||||
*/
|
||||
public Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> getActionEvaluators(CMISScope scope)
|
||||
{
|
||||
Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> evaluators = actionEvaluators.get(scope);
|
||||
if (evaluators == null)
|
||||
{
|
||||
evaluators = Collections.emptyMap();
|
||||
}
|
||||
return evaluators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an Action Evaluator
|
||||
*
|
||||
* @param scope
|
||||
* @param evaluator
|
||||
*/
|
||||
private void registerEvaluator(CMISScope scope, CMISActionEvaluator<? extends Object> evaluator)
|
||||
{
|
||||
Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> evaluators = actionEvaluators.get(scope);
|
||||
if (evaluators == null)
|
||||
{
|
||||
evaluators = new LinkedHashMap<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>>();
|
||||
actionEvaluators.put(scope, evaluators);
|
||||
}
|
||||
if (evaluators.get(evaluator.getAction()) != null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Already registered Action Evaluator " + evaluator.getAction() + " for scope " + scope);
|
||||
}
|
||||
evaluators.put(evaluator.getAction(), evaluator);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Registered Action Evaluator: scope=" + scope + ", evaluator=" + evaluator);
|
||||
}
|
||||
|
||||
public Collection<Pair<String, Boolean>> getReportedPermissions(String permission, Set<String> permissions, boolean hasFull, boolean isDirect, CMISAccessControlFormatEnum format)
|
||||
{
|
||||
ArrayList<Pair<String, Boolean>> answer = new ArrayList<Pair<String, Boolean>>(20);
|
||||
// indirect
|
||||
|
||||
if(hasFull)
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_READ_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_WRITE_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_ALL_PERMISSION, false));
|
||||
}
|
||||
|
||||
for(String perm : permissions)
|
||||
{
|
||||
if(PermissionService.READ.equals(perm))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_READ_PERMISSION, false));
|
||||
}
|
||||
else if(PermissionService.WRITE.equals(perm))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_WRITE_PERMISSION, false));
|
||||
}
|
||||
else if(PermissionService.ALL_PERMISSIONS.equals(perm))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_READ_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_WRITE_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_ALL_PERMISSION, false));
|
||||
}
|
||||
|
||||
if(hasFull)
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_READ_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_WRITE_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_ALL_PERMISSION, false));
|
||||
}
|
||||
}
|
||||
|
||||
// permission
|
||||
|
||||
if(format == CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS)
|
||||
{
|
||||
if(PermissionService.READ.equals(permission))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_READ_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(permission, isDirect));
|
||||
}
|
||||
else if(PermissionService.WRITE.equals(permission))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_WRITE_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(permission, isDirect));
|
||||
}
|
||||
else if(PermissionService.ALL_PERMISSIONS.equals(permission))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_ALL_PERMISSION, false));
|
||||
answer.add(new Pair<String, Boolean>(permission, isDirect));
|
||||
}
|
||||
else
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(permission, isDirect));
|
||||
}
|
||||
}
|
||||
else if(format == CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS)
|
||||
{
|
||||
if(PermissionService.READ.equals(permission))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_READ_PERMISSION, isDirect));
|
||||
}
|
||||
else if(PermissionService.WRITE.equals(permission))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_WRITE_PERMISSION, isDirect));
|
||||
}
|
||||
else if(PermissionService.ALL_PERMISSIONS.equals(permission))
|
||||
{
|
||||
answer.add(new Pair<String, Boolean>(CMISAccessControlService.CMIS_ALL_PERMISSION, isDirect));
|
||||
}
|
||||
else
|
||||
{
|
||||
// else nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param permission
|
||||
* @return permission to set
|
||||
*/
|
||||
public String getSetPermission(String permission)
|
||||
{
|
||||
if(permission.equals(CMISAccessControlService.CMIS_READ_PERMISSION))
|
||||
{
|
||||
return PermissionService.READ;
|
||||
}
|
||||
else if(permission.equals(CMISAccessControlService.CMIS_WRITE_PERMISSION))
|
||||
{
|
||||
return PermissionService.WRITE;
|
||||
}
|
||||
else if(permission.equals(CMISAccessControlService.CMIS_ALL_PERMISSION))
|
||||
{
|
||||
return PermissionService.ALL_PERMISSIONS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
|
||||
/**
|
||||
* Check-in operation is only allowed for PWC object per CMIS specification
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class CanCheckInActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
{
|
||||
private NodeService nodeService;
|
||||
|
||||
private PermissionActionEvaluator<NodeRef> permissionEvaluator;
|
||||
|
||||
protected CanCheckInActionEvaluator(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
super(serviceRegistry, CMISAllowedActionEnum.CAN_CHECKIN);
|
||||
|
||||
permissionEvaluator = new PermissionActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_CHECKIN, false, PermissionService.CHECK_IN);
|
||||
|
||||
nodeService = serviceRegistry.getNodeService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed(NodeRef object)
|
||||
{
|
||||
if ((null != object) && nodeService.exists(object))
|
||||
{
|
||||
return permissionEvaluator.isAllowed(object) && nodeService.hasAspect(object, ContentModel.ASPECT_WORKING_COPY);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
|
||||
/**
|
||||
* Accessor for the CMIS Checkin Comment
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class CheckinCommentProperty extends AbstractVersioningProperty
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public CheckinCommentProperty(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
super(serviceRegistry, CMISDictionaryModel.PROP_CHECKIN_COMMENT);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
{
|
||||
if (isWorkingCopy(nodeRef))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ServiceRegistry serviceRegistry = getServiceRegistry();
|
||||
String versionLabel = (String)serviceRegistry.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
|
||||
if (versionLabel == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
NodeRef versionSeries = getVersionSeries(nodeRef);
|
||||
VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries);
|
||||
if (versionHistory == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Version version = versionHistory.getVersion(versionLabel);
|
||||
if (version == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return version.getDescription();
|
||||
}
|
||||
}
|
@@ -1,205 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.cmis.mapping.ParentTypeActionEvaluator.ParentTypeEnum;
|
||||
import org.alfresco.cmis.mapping.PropertyActionEvaluator.PropertyDescriptor;
|
||||
import org.alfresco.cmis.mapping.TypeAttributeActionEvaluator.TypeDefinitionAttributeEnum;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.chemistry.abdera.ext.CMISAllowableActions;
|
||||
|
||||
/**
|
||||
* This action evaluator introduces simplified interface to construct set of conditions to determine, if an action is available for a specified object. It is generic evaluator,
|
||||
* which doesn't limit validation for any type of the objects. Also it introduces a possibility to build chain of the conditions.<br />
|
||||
* <br />
|
||||
* Evaluator allows specifying logical operation to calculate the final result, using the specified conditions: conjunction (AND operation; <b>DEFAULT</b> value) or disjunction (OR
|
||||
* operation).<br />
|
||||
* <br />
|
||||
* <b>N.B.:</b> each {@link CompositeActionEvaluator} may include other {@link CompositeActionEvaluator} conditions!
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class CompositeActionEvaluator<ObjectType> extends AbstractActionEvaluator<ObjectType>
|
||||
{
|
||||
private List<AbstractActionEvaluator<ObjectType>> conditions = new LinkedList<AbstractActionEvaluator<ObjectType>>();
|
||||
|
||||
private boolean defaultAllowing;
|
||||
|
||||
private boolean requiresDisjunction;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param defaultAllowing - {@link Boolean} value, which determines availability of action for several special cases (invalid object id, empty collection of the aspects etc.)
|
||||
* @param serviceRegistry - {@link ServiceRegistry} instance
|
||||
* @param action - {@link CMISAllowableActions} enumeration value, which determines the action to check
|
||||
*/
|
||||
public CompositeActionEvaluator(boolean defaultAllowing, ServiceRegistry serviceRegistry, CMISAllowedActionEnum action)
|
||||
{
|
||||
super(serviceRegistry, action);
|
||||
this.defaultAllowing = defaultAllowing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowed(ObjectType object)
|
||||
{
|
||||
boolean result = defaultAllowing;
|
||||
|
||||
for (AbstractActionEvaluator<ObjectType> evaluator : conditions)
|
||||
{
|
||||
result = evaluator.isAllowed(object);
|
||||
|
||||
if ((requiresDisjunction && result) || (!requiresDisjunction && !result))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link PermissionActionEvaluator} condition to the list
|
||||
*
|
||||
* @param permissions - {@link String}... collection, which specifies all the permissions, which should be checked
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addPermissionCondition(String... permissions)
|
||||
{
|
||||
if (null != permissions)
|
||||
{
|
||||
conditions.add(new PermissionActionEvaluator<ObjectType>(getServiceRegistry(), getAction(), defaultAllowing, permissions));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add {@link PropertyActionEvaluator} condition to the list. This method implies, that each property from the <code>propertyIdsAndExpectedValues</code> collection must satisfy
|
||||
* conditions, which are specified in each {@link PropertyDescriptor} instance
|
||||
*
|
||||
* @param propertyIdsAndExpectedValues - {@link PropertyDescriptor} collection, which specifies property ids and expected values or if value should not be <code>null</code>
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addPropertyCondition(PropertyDescriptor... propertyIdsAndExpectedValues)
|
||||
{
|
||||
if (null != propertyIdsAndExpectedValues)
|
||||
{
|
||||
conditions.add(new PropertyActionEvaluator<ObjectType>(getServiceRegistry(), getAction(), true, defaultAllowing, propertyIdsAndExpectedValues));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link TypeAttributeActionEvaluator} condition to the list. This method implies, that <code>attribute</code> value may be null and it is not {@link Map} or
|
||||
* {@link Collection}
|
||||
*
|
||||
* @param attribute - {@link TypeDefinitionAttributeEnum} enumeration value, which determines attribute of object type definition, which should be validated
|
||||
* @param comparator - {@link Comparable} instance, which encapsulates the logic of checking a value, received from the object type definition in accordance with
|
||||
* <code>attribute</code> parameter
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addTypeAttributeCondition(TypeDefinitionAttributeEnum attribute, Comparable<Object> comparator)
|
||||
{
|
||||
if ((null != attribute) && (null != comparator))
|
||||
{
|
||||
conditions.add(new TypeAttributeActionEvaluator<ObjectType>(attribute, new Pair<Object, Comparable<Object>>(null, comparator), true, defaultAllowing,
|
||||
getServiceRegistry(), getAction()));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link ObjectLockedActionEvaluator} condition to the list. This method implies, that object should not have <code>lockType</code> lock
|
||||
*
|
||||
* @param lockType - {@link LockType} enumeration value, which determines lock, required to check
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addLockCondition(LockType lockType)
|
||||
{
|
||||
conditions.add(new ObjectLockedActionEvaluator<ObjectType>(lockType, false, getServiceRegistry(), getAction()));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link AspectActionEvaluator} condition to the list. This method sets only 1 {@link ContentModel#ASPECT_WORKING_COPY} aspect id and it implies
|
||||
*
|
||||
* @param pwcExpected - {@link Boolean} value, which determines: <code>true</code> - object should be PWC, <code>false</code> - object should not be PWC
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addPwcCondition(boolean pwcExpected)
|
||||
{
|
||||
conditions.add(new AspectActionEvaluator<ObjectType>(getServiceRegistry(), getAction(), pwcExpected, true, defaultAllowing, ContentModel.ASPECT_WORKING_COPY));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link AspectActionEvaluator} condition to the list. This method implies, that all aspects should satisfy to the <code>expected</code> condition
|
||||
*
|
||||
* @param expected - {@link Boolean} value, which determines: <code>true</code> - aspects appliance is expected, <code>false</code> - aspects absence is expected
|
||||
* @param aspects - {@link QName}... collection, which specifies all the aspects, which should be validated
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addAspectCondition(boolean expected, QName... aspects)
|
||||
{
|
||||
conditions.add(new AspectActionEvaluator<ObjectType>(getServiceRegistry(), getAction(), expected, true, defaultAllowing, aspects));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds {@link ParentTypeActionEvaluator} condition to the list. This method implies, that parent of the <code>parentType</code> type is expected
|
||||
*
|
||||
* @param parentType - {@link ParentTypeEnum} enumeration value, which determines, validation for which parent is required: for {@link ParentTypeEnum#MULTI_FILED}, for
|
||||
* {@link ParentTypeEnum#REPOSITORY_ROOT} or for {@link ParentTypeEnum#PRIMARY_REPOSITORY_ROOT}
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addParentTypeCondition(ParentTypeEnum parentType)
|
||||
{
|
||||
conditions.add(new ParentTypeActionEvaluator<ObjectType>(getServiceRegistry(), getAction(), parentType, true));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds any condition to the list, if it is not a <code>null</code>
|
||||
*
|
||||
* @param condition - {@link AbstractActionEvaluator} instance, which determines some condition
|
||||
* @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions
|
||||
*/
|
||||
public CompositeActionEvaluator<ObjectType> addCondition(AbstractActionEvaluator<ObjectType> condition)
|
||||
{
|
||||
if (null != condition)
|
||||
{
|
||||
conditions.add(condition);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.cmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
|
||||
/**
|
||||
* Accessor for CMIS content stream property id
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class ContentStreamIdProperty extends AbstractProperty
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public ContentStreamIdProperty(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
super(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_ID);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
{
|
||||
Serializable sValue = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT);
|
||||
if (sValue != null)
|
||||
{
|
||||
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, sValue);
|
||||
return contentData.getContentUrl();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user