From a89276be19c8f25c5b90e5a3f73131b9da56066d Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Tue, 22 Jul 2014 12:58:48 +0000 Subject: [PATCH] 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 --- .../application-context-highlevel.xml | 1 - config/alfresco/cmis-api-context.xml | 133 - config/alfresco/minimal-context.xml | 1 - config/alfresco/opencmis-context.xml | 9 + .../Search/lucene/cmis-api-context.xml | 51 - .../Search/noindex/cmis-api-context.xml | 21 - .../Search/solr/cmis-api-context.xml | 24 - ...essControlEntriesGroupedByPrincipalId.java | 48 - .../alfresco/cmis/CMISAccessControlEntry.java | 48 - .../cmis/CMISAccessControlReport.java | 58 - .../cmis/CMISAccessControlService.java | 127 - .../alfresco/cmis/CMISAclCapabilityEnum.java | 71 - .../alfresco/cmis/CMISAclPropagationEnum.java | 76 - .../cmis/CMISAclSupportedPermissionEnum.java | 70 - .../alfresco/cmis/CMISActionEvaluator.java | 38 - .../alfresco/cmis/CMISAllowedActionEnum.java | 122 - .../alfresco/cmis/CMISBaseObjectTypeIds.java | 50 - .../alfresco/cmis/CMISCapabilityChanges.java | 46 - .../alfresco/cmis/CMISCardinalityEnum.java | 56 - .../org/alfresco/cmis/CMISChangeEvent.java | 60 - .../java/org/alfresco/cmis/CMISChangeLog.java | 52 - .../alfresco/cmis/CMISChangeLogService.java | 80 - .../org/alfresco/cmis/CMISChangeType.java | 50 - source/java/org/alfresco/cmis/CMISChoice.java | 127 - .../cmis/CMISConstraintException.java | 40 - .../CMISContentAlreadyExistsException.java | 34 - .../cmis/CMISContentStreamAllowedEnum.java | 57 - .../org/alfresco/cmis/CMISDataTypeEnum.java | 115 - .../alfresco/cmis/CMISDictionaryModel.java | 68 - .../alfresco/cmis/CMISDictionaryService.java | 110 - .../cmis/CMISFilterNotValidException.java | 34 - .../cmis/CMISInvalidArgumentException.java | 39 - .../java/org/alfresco/cmis/CMISJoinEnum.java | 57 - .../cmis/CMISNotSupportedException.java | 39 - .../cmis/CMISObjectNotFoundException.java | 29 - .../alfresco/cmis/CMISObjectReference.java | 39 - .../cmis/CMISPermissionDefinition.java | 42 - .../cmis/CMISPermissionDeniedException.java | 39 - .../alfresco/cmis/CMISPermissionMapping.java | 46 - .../alfresco/cmis/CMISPropertyAccessor.java | 71 - .../alfresco/cmis/CMISPropertyDefinition.java | 166 - .../org/alfresco/cmis/CMISPropertyId.java | 138 - .../java/org/alfresco/cmis/CMISQueryEnum.java | 58 - .../org/alfresco/cmis/CMISQueryException.java | 76 - .../org/alfresco/cmis/CMISQueryOptions.java | 171 - .../org/alfresco/cmis/CMISQueryService.java | 71 - .../cmis/CMISRelationshipDirectionEnum.java | 57 - .../cmis/CMISRelationshipReference.java | 40 - .../java/org/alfresco/cmis/CMISRendition.java | 84 - .../alfresco/cmis/CMISRenditionService.java | 42 - .../cmis/CMISRepositoryReference.java | 35 - .../java/org/alfresco/cmis/CMISResultSet.java | 53 - .../alfresco/cmis/CMISResultSetColumn.java | 43 - .../alfresco/cmis/CMISResultSetMetaData.java | 75 - .../org/alfresco/cmis/CMISResultSetRow.java | 36 - .../alfresco/cmis/CMISResultSetSelector.java | 38 - .../alfresco/cmis/CMISRuntimeException.java | 39 - source/java/org/alfresco/cmis/CMISScope.java | 65 - .../alfresco/cmis/CMISServiceException.java | 107 - .../java/org/alfresco/cmis/CMISServices.java | 893 --- .../cmis/CMISStreamNotSupportedException.java | 35 - .../org/alfresco/cmis/CMISTypeDefinition.java | 186 - source/java/org/alfresco/cmis/CMISTypeId.java | 162 - .../alfresco/cmis/CMISTypesFilterEnum.java | 58 - .../alfresco/cmis/CMISUpdatabilityEnum.java | 58 - .../cmis/CMISVersioningException.java | 39 - .../cmis/CMISVersioningStateEnum.java | 56 - .../org/alfresco/cmis/PropertyFilter.java | 134 - ...ontrolEntriesGroupedByPrincipalIdImpl.java | 87 - .../cmis/acl/CMISAccessControlEntryImpl.java | 155 - .../cmis/acl/CMISAccessControlReportImpl.java | 108 - .../acl/CMISAccessControlServiceImpl.java | 507 -- .../acl/CMISAllowedActionKeyTypeEnum.java | 85 - .../acl/CMISPermissionDefinitionImpl.java | 105 - .../cmis/acl/CMISPermissionMappingImpl.java | 57 - .../cmis/acl/CMISPermissionMappingKey.java | 40 - .../cmis/changelog/CMISChangeEventImpl.java | 122 - .../cmis/changelog/CMISChangeLogImpl.java | 100 - .../changelog/CMISChangeLogServiceImpl.java | 346 - .../CMISAbstractDictionaryService.java | 564 -- .../CMISAbstractTypeDefinition.java | 523 -- .../CMISBasePropertyDefinition.java | 420 -- .../CMISDocumentTypeDefinition.java | 156 - .../dictionary/CMISFolderTypeDefinition.java | 127 - .../dictionary/CMISObjectTypeDefinition.java | 125 - .../dictionary/CMISPolicyTypeDefinition.java | 152 - .../CMISRelationshipTypeDefinition.java | 264 - .../CMISStrictDictionaryService.java | 137 - .../cmis/mapping/AbstractActionEvaluator.java | 64 - .../cmis/mapping/AbstractProperty.java | 174 - .../cmis/mapping/AbstractSimpleProperty.java | 155 - .../mapping/AbstractVersioningProperty.java | 82 - .../cmis/mapping/AspectActionEvaluator.java | 104 - .../cmis/mapping/BaseTypeIdProperty.java | 117 - .../alfresco/cmis/mapping/CMISMapping.java | 982 --- .../cmis/mapping/CMISServicesImpl.java | 1995 ------ .../mapping/CanCheckInActionEvaluator.java | 58 - .../cmis/mapping/CheckinCommentProperty.java | 76 - .../mapping/CompositeActionEvaluator.java | 205 - .../cmis/mapping/ContentStreamIdProperty.java | 62 - .../mapping/ContentStreamLengthProperty.java | 93 - .../ContentStreamMimetypeProperty.java | 92 - .../alfresco/cmis/mapping/DirectProperty.java | 178 - .../mapping/FixedValueActionEvaluator.java | 63 - .../cmis/mapping/FixedValueProperty.java | 276 - .../cmis/mapping/IsImmutableProperty.java | 60 - .../mapping/IsLatestMajorVersionProperty.java | 103 - .../cmis/mapping/IsLatestVersionProperty.java | 81 - .../cmis/mapping/IsMajorVersionProperty.java | 71 - .../IsVersionSeriesCheckedOutProperty.java | 52 - .../cmis/mapping/ObjectIdProperty.java | 201 - .../mapping/ObjectLockedActionEvaluator.java | 80 - .../cmis/mapping/ObjectTypeIdProperty.java | 179 - .../cmis/mapping/ParentActionEvaluator.java | 77 - .../alfresco/cmis/mapping/ParentProperty.java | 137 - .../mapping/ParentTypeActionEvaluator.java | 131 - .../alfresco/cmis/mapping/PathProperty.java | 128 - .../mapping/PermissionActionEvaluator.java | 91 - .../cmis/mapping/PropertyActionEvaluator.java | 200 - .../cmis/mapping/RootActionEvaluator.java | 71 - .../cmis/mapping/SourceIdProperty.java | 52 - .../cmis/mapping/TargetIdProperty.java | 52 - .../mapping/TypeAttributeActionEvaluator.java | 303 - .../cmis/mapping/VersionLabelProperty.java | 60 - .../VersionSeriesCheckedOutByProperty.java | 62 - .../VersionSeriesCheckedOutIdProperty.java | 65 - .../cmis/mapping/VersionSeriesIdProperty.java | 60 - .../cmis/renditions/CMISRenditionImpl.java | 266 - .../renditions/CMISRenditionServiceImpl.java | 502 -- .../cmis/search/CMISFTSQueryParser.java | 417 -- .../alfresco/cmis/search/CMISQueryParser.java | 1666 ----- .../cmis/search/CMISQueryServiceImpl.java | 227 - .../cmis/search/CMISResultSetColumnImpl.java | 89 - .../cmis/search/CMISResultSetImpl.java | 357 - .../search/CMISResultSetMetaDataImpl.java | 200 - .../cmis/search/CMISResultSetRowImpl.java | 252 - .../search/CMISResultSetRowIteratorImpl.java | 132 - .../search/CMISResultSetSelectorImpl.java | 64 - .../search/CmisFunctionEvaluationContext.java | 494 -- .../opencmis/AlfrescoCmisServiceImpl.java | 3 +- .../org/alfresco/opencmis/CMISConnector.java | 3 +- .../mapping/CheckinCommentProperty.java | 4 +- .../impl/lucene/ADMLuceneSearcherImpl.java | 36 +- .../LuceneAlfrescoSqlQueryLanguage.java | 14 +- .../LuceneCmisStrictSqlQueryLanguage.java | 14 +- .../impl/lucene/PagingLuceneResultSet.java | 10 +- .../noindex/NoIndexCMISQueryServiceImpl.java | 168 - .../impl/solr/SolrCMISQueryServiceImpl.java | 173 - .../ACLEntryAfterInvocationProvider.java | 2 +- .../service/ServiceDescriptorRegistry.java | 11 +- .../org/alfresco/service/ServiceRegistry.java | 12 +- .../org/alfresco/AllUnitTestsSuite.java | 1 - .../org/alfresco/Repository01TestSuite.java | 9 - .../org/alfresco/Repository02TestSuite.java | 37 - .../org/alfresco/cmis/PropertyFilterTest.java | 144 - .../acl/CMISAccessControlServiceTest.java | 589 -- .../cmis/dictionary/CMISDictionaryTest.java | 83 - .../alfresco/cmis/mapping/BaseCMISTest.java | 179 - .../cmis/mapping/CMISPropertyServiceTest.java | 922 --- .../renditions/CMISRenditionServiceTest.java | 389 -- .../org/alfresco/cmis/search/QueryTest.java | 5846 ----------------- .../org/alfresco/opencmis/CMISTest.java | 17 +- .../rendition/MockedTestServiceRegistry.java | 12 +- 163 files changed, 44 insertions(+), 29865 deletions(-) delete mode 100644 config/alfresco/cmis-api-context.xml delete mode 100644 config/alfresco/subsystems/Search/lucene/cmis-api-context.xml delete mode 100644 config/alfresco/subsystems/Search/noindex/cmis-api-context.xml delete mode 100644 config/alfresco/subsystems/Search/solr/cmis-api-context.xml delete mode 100644 source/java/org/alfresco/cmis/CMISAccessControlEntriesGroupedByPrincipalId.java delete mode 100644 source/java/org/alfresco/cmis/CMISAccessControlEntry.java delete mode 100644 source/java/org/alfresco/cmis/CMISAccessControlReport.java delete mode 100644 source/java/org/alfresco/cmis/CMISAccessControlService.java delete mode 100644 source/java/org/alfresco/cmis/CMISAclCapabilityEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISAclPropagationEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISAclSupportedPermissionEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/CMISAllowedActionEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISBaseObjectTypeIds.java delete mode 100644 source/java/org/alfresco/cmis/CMISCapabilityChanges.java delete mode 100644 source/java/org/alfresco/cmis/CMISCardinalityEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISChangeEvent.java delete mode 100644 source/java/org/alfresco/cmis/CMISChangeLog.java delete mode 100644 source/java/org/alfresco/cmis/CMISChangeLogService.java delete mode 100644 source/java/org/alfresco/cmis/CMISChangeType.java delete mode 100644 source/java/org/alfresco/cmis/CMISChoice.java delete mode 100644 source/java/org/alfresco/cmis/CMISConstraintException.java delete mode 100644 source/java/org/alfresco/cmis/CMISContentAlreadyExistsException.java delete mode 100644 source/java/org/alfresco/cmis/CMISContentStreamAllowedEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISDataTypeEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISDictionaryModel.java delete mode 100644 source/java/org/alfresco/cmis/CMISDictionaryService.java delete mode 100644 source/java/org/alfresco/cmis/CMISFilterNotValidException.java delete mode 100644 source/java/org/alfresco/cmis/CMISInvalidArgumentException.java delete mode 100644 source/java/org/alfresco/cmis/CMISJoinEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISNotSupportedException.java delete mode 100644 source/java/org/alfresco/cmis/CMISObjectNotFoundException.java delete mode 100644 source/java/org/alfresco/cmis/CMISObjectReference.java delete mode 100644 source/java/org/alfresco/cmis/CMISPermissionDefinition.java delete mode 100644 source/java/org/alfresco/cmis/CMISPermissionDeniedException.java delete mode 100644 source/java/org/alfresco/cmis/CMISPermissionMapping.java delete mode 100644 source/java/org/alfresco/cmis/CMISPropertyAccessor.java delete mode 100644 source/java/org/alfresco/cmis/CMISPropertyDefinition.java delete mode 100644 source/java/org/alfresco/cmis/CMISPropertyId.java delete mode 100644 source/java/org/alfresco/cmis/CMISQueryEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISQueryException.java delete mode 100644 source/java/org/alfresco/cmis/CMISQueryOptions.java delete mode 100644 source/java/org/alfresco/cmis/CMISQueryService.java delete mode 100644 source/java/org/alfresco/cmis/CMISRelationshipDirectionEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISRelationshipReference.java delete mode 100644 source/java/org/alfresco/cmis/CMISRendition.java delete mode 100644 source/java/org/alfresco/cmis/CMISRenditionService.java delete mode 100644 source/java/org/alfresco/cmis/CMISRepositoryReference.java delete mode 100644 source/java/org/alfresco/cmis/CMISResultSet.java delete mode 100644 source/java/org/alfresco/cmis/CMISResultSetColumn.java delete mode 100644 source/java/org/alfresco/cmis/CMISResultSetMetaData.java delete mode 100644 source/java/org/alfresco/cmis/CMISResultSetRow.java delete mode 100644 source/java/org/alfresco/cmis/CMISResultSetSelector.java delete mode 100644 source/java/org/alfresco/cmis/CMISRuntimeException.java delete mode 100644 source/java/org/alfresco/cmis/CMISScope.java delete mode 100644 source/java/org/alfresco/cmis/CMISServiceException.java delete mode 100644 source/java/org/alfresco/cmis/CMISServices.java delete mode 100644 source/java/org/alfresco/cmis/CMISStreamNotSupportedException.java delete mode 100644 source/java/org/alfresco/cmis/CMISTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/CMISTypeId.java delete mode 100644 source/java/org/alfresco/cmis/CMISTypesFilterEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISUpdatabilityEnum.java delete mode 100644 source/java/org/alfresco/cmis/CMISVersioningException.java delete mode 100644 source/java/org/alfresco/cmis/CMISVersioningStateEnum.java delete mode 100644 source/java/org/alfresco/cmis/PropertyFilter.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISAccessControlEntriesGroupedByPrincipalIdImpl.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISAccessControlEntryImpl.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISAccessControlReportImpl.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISAccessControlServiceImpl.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISAllowedActionKeyTypeEnum.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISPermissionDefinitionImpl.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISPermissionMappingImpl.java delete mode 100644 source/java/org/alfresco/cmis/acl/CMISPermissionMappingKey.java delete mode 100644 source/java/org/alfresco/cmis/changelog/CMISChangeEventImpl.java delete mode 100644 source/java/org/alfresco/cmis/changelog/CMISChangeLogImpl.java delete mode 100644 source/java/org/alfresco/cmis/changelog/CMISChangeLogServiceImpl.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java delete mode 100644 source/java/org/alfresco/cmis/dictionary/CMISStrictDictionaryService.java delete mode 100644 source/java/org/alfresco/cmis/mapping/AbstractActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/AbstractProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/AbstractSimpleProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/AbstractVersioningProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/AspectActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/BaseTypeIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/CMISMapping.java delete mode 100644 source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java delete mode 100644 source/java/org/alfresco/cmis/mapping/CanCheckInActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/CheckinCommentProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/CompositeActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ContentStreamIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ContentStreamLengthProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ContentStreamMimetypeProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/DirectProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/FixedValueActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/FixedValueProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/IsImmutableProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/IsLatestMajorVersionProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/IsLatestVersionProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/IsMajorVersionProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/IsVersionSeriesCheckedOutProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ObjectLockedActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ObjectTypeIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ParentActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ParentProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/ParentTypeActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/PathProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/PermissionActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/PropertyActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/RootActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/SourceIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/TargetIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/TypeAttributeActionEvaluator.java delete mode 100644 source/java/org/alfresco/cmis/mapping/VersionLabelProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutByProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/mapping/VersionSeriesIdProperty.java delete mode 100644 source/java/org/alfresco/cmis/renditions/CMISRenditionImpl.java delete mode 100644 source/java/org/alfresco/cmis/renditions/CMISRenditionServiceImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISFTSQueryParser.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISQueryParser.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISQueryServiceImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISResultSetColumnImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISResultSetImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISResultSetMetaDataImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISResultSetRowIteratorImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CMISResultSetSelectorImpl.java delete mode 100644 source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java delete mode 100644 source/java/org/alfresco/repo/search/impl/noindex/NoIndexCMISQueryServiceImpl.java delete mode 100644 source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryServiceImpl.java delete mode 100644 source/test-java/org/alfresco/Repository02TestSuite.java delete mode 100644 source/test-java/org/alfresco/cmis/PropertyFilterTest.java delete mode 100644 source/test-java/org/alfresco/cmis/acl/CMISAccessControlServiceTest.java delete mode 100644 source/test-java/org/alfresco/cmis/dictionary/CMISDictionaryTest.java delete mode 100644 source/test-java/org/alfresco/cmis/mapping/BaseCMISTest.java delete mode 100644 source/test-java/org/alfresco/cmis/mapping/CMISPropertyServiceTest.java delete mode 100644 source/test-java/org/alfresco/cmis/renditions/CMISRenditionServiceTest.java delete mode 100644 source/test-java/org/alfresco/cmis/search/QueryTest.java diff --git a/config/alfresco/application-context-highlevel.xml b/config/alfresco/application-context-highlevel.xml index 5c949bcd04..751f7ec5d1 100644 --- a/config/alfresco/application-context-highlevel.xml +++ b/config/alfresco/application-context-highlevel.xml @@ -28,7 +28,6 @@ - diff --git a/config/alfresco/cmis-api-context.xml b/config/alfresco/cmis-api-context.xml deleted file mode 100644 index 6758257f5d..0000000000 --- a/config/alfresco/cmis-api-context.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - 1.0 - Version 1.0 OASIS Standard - ${spaces.store} - /${spaces.company_home.childname} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - alfresco/model/cmisModel.xml - alfresco/model/cmisTestModel.xml - - - - - - - - - - search.CMISQueryService - - - - org.alfresco.cmis.CMISQueryService - - - - - - - - - doclib - - - webpreviewimgpreview - - - - - - - alf:icon16 - image/gif - alf:icon16 - 16 - 16 - - - alf:icon32 - image/gif - alf:icon32 - 32 - 32 - - - - - - - - - - - - - - - - FOLDER - DOCUMENT - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/minimal-context.xml b/config/alfresco/minimal-context.xml index 46010fcb4e..0cca4aca3c 100644 --- a/config/alfresco/minimal-context.xml +++ b/config/alfresco/minimal-context.xml @@ -13,7 +13,6 @@ - diff --git a/config/alfresco/opencmis-context.xml b/config/alfresco/opencmis-context.xml index 8561513ca9..60eacd1421 100644 --- a/config/alfresco/opencmis-context.xml +++ b/config/alfresco/opencmis-context.xml @@ -4,6 +4,15 @@ + + + + alfresco/model/cmisModel.xml + alfresco/model/cmisTestModel.xml + + + + diff --git a/config/alfresco/subsystems/Search/lucene/cmis-api-context.xml b/config/alfresco/subsystems/Search/lucene/cmis-api-context.xml deleted file mode 100644 index 38706a98dc..0000000000 --- a/config/alfresco/subsystems/Search/lucene/cmis-api-context.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - org.alfresco.repo.search.impl.querymodel.QueryEngine - - - - - - - - - - - - - - - - - - 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 - - - - - diff --git a/config/alfresco/subsystems/Search/noindex/cmis-api-context.xml b/config/alfresco/subsystems/Search/noindex/cmis-api-context.xml deleted file mode 100644 index 5242455356..0000000000 --- a/config/alfresco/subsystems/Search/noindex/cmis-api-context.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/subsystems/Search/solr/cmis-api-context.xml b/config/alfresco/subsystems/Search/solr/cmis-api-context.xml deleted file mode 100644 index 1199197860..0000000000 --- a/config/alfresco/subsystems/Search/solr/cmis-api-context.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/java/org/alfresco/cmis/CMISAccessControlEntriesGroupedByPrincipalId.java b/source/java/org/alfresco/cmis/CMISAccessControlEntriesGroupedByPrincipalId.java deleted file mode 100644 index fdf4656eb7..0000000000 --- a/source/java/org/alfresco/cmis/CMISAccessControlEntriesGroupedByPrincipalId.java +++ /dev/null @@ -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 . - */ -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 getDirectPermissions(); - - /** - * Get the indirect permissions - * @return the indirect permissions - */ - public List getIndirectPermissions(); - - -} diff --git a/source/java/org/alfresco/cmis/CMISAccessControlEntry.java b/source/java/org/alfresco/cmis/CMISAccessControlEntry.java deleted file mode 100644 index d75fb0b7de..0000000000 --- a/source/java/org/alfresco/cmis/CMISAccessControlEntry.java +++ /dev/null @@ -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 . - */ -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 true if directly assigned, false otherwise. - */ - public boolean getDirect(); -} diff --git a/source/java/org/alfresco/cmis/CMISAccessControlReport.java b/source/java/org/alfresco/cmis/CMISAccessControlReport.java deleted file mode 100644 index ae4571826a..0000000000 --- a/source/java/org/alfresco/cmis/CMISAccessControlReport.java +++ /dev/null @@ -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 . - */ -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 getAccessControlEntries(); - - /** - * Is this report exact? - * If false 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 true means the report fully describes security access, false means other - * security constraints may apply but are not reported. - */ - public boolean isExact(); - - /** - * Get ACEs grouped by principal id - * @return ACEs grouped by principal id - * @throws CMISConstraintException - */ - public List getAccessControlEntriesGroupedByPrincipalId() throws CMISConstraintException; - - -} diff --git a/source/java/org/alfresco/cmis/CMISAccessControlService.java b/source/java/org/alfresco/cmis/CMISAccessControlService.java deleted file mode 100644 index 0a7edf48a6..0000000000 --- a/source/java/org/alfresco/cmis/CMISAccessControlService.java +++ /dev/null @@ -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 . - */ -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 getRepositoryPermissions(); - - /** - * Get the list of permission mappings. - * @return get the permission mapping as defined by the CMIS specification. - */ - public List 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 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 acesToRemove, List acesToAdd, CMISAclPropagationEnum propagation, CMISAccessControlFormatEnum format) throws CMISConstraintException; -} diff --git a/source/java/org/alfresco/cmis/CMISAclCapabilityEnum.java b/source/java/org/alfresco/cmis/CMISAclCapabilityEnum.java deleted file mode 100644 index ca3ef62dcb..0000000000 --- a/source/java/org/alfresco/cmis/CMISAclCapabilityEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISAclCapabilityEnum.class, MANAGE, true); - -} diff --git a/source/java/org/alfresco/cmis/CMISAclPropagationEnum.java b/source/java/org/alfresco/cmis/CMISAclPropagationEnum.java deleted file mode 100644 index 00cfa75d40..0000000000 --- a/source/java/org/alfresco/cmis/CMISAclPropagationEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISAclPropagationEnum.class, PROPAGATE, true); - -} diff --git a/source/java/org/alfresco/cmis/CMISAclSupportedPermissionEnum.java b/source/java/org/alfresco/cmis/CMISAclSupportedPermissionEnum.java deleted file mode 100644 index d2869b4c01..0000000000 --- a/source/java/org/alfresco/cmis/CMISAclSupportedPermissionEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory( - CMISAclSupportedPermissionEnum.class, BOTH, true); - -} diff --git a/source/java/org/alfresco/cmis/CMISActionEvaluator.java b/source/java/org/alfresco/cmis/CMISActionEvaluator.java deleted file mode 100644 index be2b264d69..0000000000 --- a/source/java/org/alfresco/cmis/CMISActionEvaluator.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - - -public interface CMISActionEvaluator -{ - /** - * 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); -} diff --git a/source/java/org/alfresco/cmis/CMISAllowedActionEnum.java b/source/java/org/alfresco/cmis/CMISAllowedActionEnum.java deleted file mode 100644 index 86b8b58f8d..0000000000 --- a/source/java/org/alfresco/cmis/CMISAllowedActionEnum.java +++ /dev/null @@ -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 . - */ -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> mapping = new HashMap>(); - - /** - * 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 permissions = mapping.get(key); - if(permissions == null) - { - permissions = new ArrayList(1); - mapping.put(key, permissions); - } - permissions.add(permission); - } - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.EnumLabel#label() - */ - public String getLabel() - { - return label; - } - - public Map> getPermissionMapping() - { - return mapping; - } - - public static EnumFactory FACTORY = new EnumFactory(CMISAllowedActionEnum.class); -} diff --git a/source/java/org/alfresco/cmis/CMISBaseObjectTypeIds.java b/source/java/org/alfresco/cmis/CMISBaseObjectTypeIds.java deleted file mode 100644 index 3ac8cf3c04..0000000000 --- a/source/java/org/alfresco/cmis/CMISBaseObjectTypeIds.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import org.alfresco.opencmis.EnumFactory; -import org.alfresco.opencmis.EnumLabel; - -/** - * Enumeration of base Alfresco Object type Ids. Possible values:
- * DOCUMENT,
- * FOLDER,
- * RELATIONSHIP,
- * POLICY - * - * @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 FACTORY = new EnumFactory(CMISBaseObjectTypeIds.class); -} diff --git a/source/java/org/alfresco/cmis/CMISCapabilityChanges.java b/source/java/org/alfresco/cmis/CMISCapabilityChanges.java deleted file mode 100644 index 5ac4253cc4..0000000000 --- a/source/java/org/alfresco/cmis/CMISCapabilityChanges.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import org.alfresco.opencmis.EnumFactory; -import org.alfresco.opencmis.EnumLabel; - -/** - * Enumeration of the CMIS Changes Capability - * - * @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 FACTORY = new EnumFactory(CMISCapabilityChanges.class); -} diff --git a/source/java/org/alfresco/cmis/CMISCardinalityEnum.java b/source/java/org/alfresco/cmis/CMISCardinalityEnum.java deleted file mode 100644 index a461abd0fb..0000000000 --- a/source/java/org/alfresco/cmis/CMISCardinalityEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISCardinalityEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/CMISChangeEvent.java b/source/java/org/alfresco/cmis/CMISChangeEvent.java deleted file mode 100644 index 0567b803b9..0000000000 --- a/source/java/org/alfresco/cmis/CMISChangeEvent.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import java.util.Date; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * This class describes entry record for some Change Log descriptor. - * - * @author Dmitry Velichkevich - */ -public interface CMISChangeEvent -{ - /** - * Gets the change type. - * - * @return {@link CMISChangeType} enum value that determines the type of current Change Event - */ - public CMISChangeType getChangeType(); - - /** - * Gets the change time. - * - * @return {@link Date} value that represents time of current Change Event - */ - 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(); - -} diff --git a/source/java/org/alfresco/cmis/CMISChangeLog.java b/source/java/org/alfresco/cmis/CMISChangeLog.java deleted file mode 100644 index a33810c5df..0000000000 --- a/source/java/org/alfresco/cmis/CMISChangeLog.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import java.util.List; - -/** - * This class represents descriptor for some Change Log Token - * - * @author Dmitry Velichkevich - */ -public interface CMISChangeLog -{ - /** - * @return {@link List}<{@link CMISChangeEvent}> collection that contains all available for some Change Log Token Change Events descriptors - */ - public List getChangeEvents(); - - /** - * @return {@link Boolean} value that determines whether repository contains any more Change Events after some {@link CMISChangeLogService}.{@link #getChangeEvents()} - * invocation - */ - public boolean hasMoreItems(); - - /** - * Note: this is optional operation and actual Change Events amount in collection may not be equal to result of this method invocation - * - * @return {@link Integer} value that determines amount of Change Events those were returned - */ - public Integer getEventCount(); - - /** - * @return {@link String} value that represents the next generated Change Log Token - */ - public String getNextChangeToken(); -} diff --git a/source/java/org/alfresco/cmis/CMISChangeLogService.java b/source/java/org/alfresco/cmis/CMISChangeLogService.java deleted file mode 100644 index 1c6eaa0252..0000000000 --- a/source/java/org/alfresco/cmis/CMISChangeLogService.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import java.util.List; - -/** - * Service for manipulating with Change Log Events by Change Log Tokens. Also this service exposes some methods for describing Auditing features - * - * @author Dmitry Velichkevich - */ -public interface CMISChangeLogService -{ - /** - * @param changeLogToken - {@link String} value that represents some Change Log Token - * @param maxItems - {@link Integer} value that determines required amount of entries - * @return {@link CMISChangeLog} instance that describes entry mapped to specified Change Log Token - * @throws CMISInvalidArgumentException - */ - public CMISChangeLog getChangeLogEvents(String changeLogToken, Integer maxItems) throws CMISInvalidArgumentException; - - /** - * @return {@link String} value that represents Change Log Token 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} enum value that specifies currently configured Auditing 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 getChangesOnTypeCapability(); - - /** - * @return always true - */ - public boolean getChangesIncomplete(); -} diff --git a/source/java/org/alfresco/cmis/CMISChangeType.java b/source/java/org/alfresco/cmis/CMISChangeType.java deleted file mode 100644 index 928a4c1bd7..0000000000 --- a/source/java/org/alfresco/cmis/CMISChangeType.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import org.alfresco.opencmis.EnumFactory; -import org.alfresco.opencmis.EnumLabel; - -/** - * Enumeration of the CMIS Change Type. Possible values:
- * CREATED
- * UPDATED
- * DELETED
- * SECURITY - * - * @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 FACTORY = new EnumFactory(CMISChangeType.class); -} diff --git a/source/java/org/alfresco/cmis/CMISChoice.java b/source/java/org/alfresco/cmis/CMISChoice.java deleted file mode 100644 index 1984c64b4f..0000000000 --- a/source/java/org/alfresco/cmis/CMISChoice.java +++ /dev/null @@ -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 . - */ -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 choices = new HashSet(); - - 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 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(); - } -} diff --git a/source/java/org/alfresco/cmis/CMISConstraintException.java b/source/java/org/alfresco/cmis/CMISConstraintException.java deleted file mode 100644 index 5e0ec61c9a..0000000000 --- a/source/java/org/alfresco/cmis/CMISConstraintException.java +++ /dev/null @@ -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 . - */ -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); - } - -} diff --git a/source/java/org/alfresco/cmis/CMISContentAlreadyExistsException.java b/source/java/org/alfresco/cmis/CMISContentAlreadyExistsException.java deleted file mode 100644 index 3eb2456227..0000000000 --- a/source/java/org/alfresco/cmis/CMISContentAlreadyExistsException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISContentStreamAllowedEnum.java b/source/java/org/alfresco/cmis/CMISContentStreamAllowedEnum.java deleted file mode 100644 index 538a300b92..0000000000 --- a/source/java/org/alfresco/cmis/CMISContentStreamAllowedEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISContentStreamAllowedEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/CMISDataTypeEnum.java b/source/java/org/alfresco/cmis/CMISDataTypeEnum.java deleted file mode 100644 index 765e70a385..0000000000 --- a/source/java/org/alfresco/cmis/CMISDataTypeEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISDataTypeEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/CMISDictionaryModel.java b/source/java/org/alfresco/cmis/CMISDictionaryModel.java deleted file mode 100644 index 61fea4dc54..0000000000 --- a/source/java/org/alfresco/cmis/CMISDictionaryModel.java +++ /dev/null @@ -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 . - */ -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"; - -} diff --git a/source/java/org/alfresco/cmis/CMISDictionaryService.java b/source/java/org/alfresco/cmis/CMISDictionaryService.java deleted file mode 100644 index ca5f98948d..0000000000 --- a/source/java/org/alfresco/cmis/CMISDictionaryService.java +++ /dev/null @@ -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 . - */ -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 getBaseTypes(); - - /** - * Get all Types - * - * @return - */ - public Collection 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); - -} diff --git a/source/java/org/alfresco/cmis/CMISFilterNotValidException.java b/source/java/org/alfresco/cmis/CMISFilterNotValidException.java deleted file mode 100644 index f4f63d6d7c..0000000000 --- a/source/java/org/alfresco/cmis/CMISFilterNotValidException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISInvalidArgumentException.java b/source/java/org/alfresco/cmis/CMISInvalidArgumentException.java deleted file mode 100644 index a95ff20e48..0000000000 --- a/source/java/org/alfresco/cmis/CMISInvalidArgumentException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISJoinEnum.java b/source/java/org/alfresco/cmis/CMISJoinEnum.java deleted file mode 100644 index dff61415fe..0000000000 --- a/source/java/org/alfresco/cmis/CMISJoinEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISJoinEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/CMISNotSupportedException.java b/source/java/org/alfresco/cmis/CMISNotSupportedException.java deleted file mode 100644 index bdf3b4393a..0000000000 --- a/source/java/org/alfresco/cmis/CMISNotSupportedException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISObjectNotFoundException.java b/source/java/org/alfresco/cmis/CMISObjectNotFoundException.java deleted file mode 100644 index f89a5ff04f..0000000000 --- a/source/java/org/alfresco/cmis/CMISObjectNotFoundException.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -public class CMISObjectNotFoundException extends CMISServiceException -{ - private static final long serialVersionUID = 1726826685938651586L; - - public CMISObjectNotFoundException(String message) - { - super(message, "objectNotFound", 404); - } -} diff --git a/source/java/org/alfresco/cmis/CMISObjectReference.java b/source/java/org/alfresco/cmis/CMISObjectReference.java deleted file mode 100644 index 8a165bb8d1..0000000000 --- a/source/java/org/alfresco/cmis/CMISObjectReference.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISPermissionDefinition.java b/source/java/org/alfresco/cmis/CMISPermissionDefinition.java deleted file mode 100644 index 2cae6858ea..0000000000 --- a/source/java/org/alfresco/cmis/CMISPermissionDefinition.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISPermissionDeniedException.java b/source/java/org/alfresco/cmis/CMISPermissionDeniedException.java deleted file mode 100644 index 5a59a47eba..0000000000 --- a/source/java/org/alfresco/cmis/CMISPermissionDeniedException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISPermissionMapping.java b/source/java/org/alfresco/cmis/CMISPermissionMapping.java deleted file mode 100644 index 440f623474..0000000000 --- a/source/java/org/alfresco/cmis/CMISPermissionMapping.java +++ /dev/null @@ -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 . - */ -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 getPermissions(); -} diff --git a/source/java/org/alfresco/cmis/CMISPropertyAccessor.java b/source/java/org/alfresco/cmis/CMISPropertyAccessor.java deleted file mode 100644 index 9437fa1594..0000000000 --- a/source/java/org/alfresco/cmis/CMISPropertyAccessor.java +++ /dev/null @@ -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 . - */ -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); -} diff --git a/source/java/org/alfresco/cmis/CMISPropertyDefinition.java b/source/java/org/alfresco/cmis/CMISPropertyDefinition.java deleted file mode 100644 index 0b897aeec0..0000000000 --- a/source/java/org/alfresco/cmis/CMISPropertyDefinition.java +++ /dev/null @@ -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 . - */ -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 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(); -} diff --git a/source/java/org/alfresco/cmis/CMISPropertyId.java b/source/java/org/alfresco/cmis/CMISPropertyId.java deleted file mode 100644 index ea83965b62..0000000000 --- a/source/java/org/alfresco/cmis/CMISPropertyId.java +++ /dev/null @@ -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 . - */ -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; - } - -} diff --git a/source/java/org/alfresco/cmis/CMISQueryEnum.java b/source/java/org/alfresco/cmis/CMISQueryEnum.java deleted file mode 100644 index 4b5f423b26..0000000000 --- a/source/java/org/alfresco/cmis/CMISQueryEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISQueryEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/CMISQueryException.java b/source/java/org/alfresco/cmis/CMISQueryException.java deleted file mode 100644 index 6d6b969e00..0000000000 --- a/source/java/org/alfresco/cmis/CMISQueryException.java +++ /dev/null @@ -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 . - */ -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 - } - -} diff --git a/source/java/org/alfresco/cmis/CMISQueryOptions.java b/source/java/org/alfresco/cmis/CMISQueryOptions.java deleted file mode 100644 index 3c409a0166..0000000000 --- a/source/java/org/alfresco/cmis/CMISQueryOptions.java +++ /dev/null @@ -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 . - */ -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; - } -} - - diff --git a/source/java/org/alfresco/cmis/CMISQueryService.java b/source/java/org/alfresco/cmis/CMISQueryService.java deleted file mode 100644 index 4cea3eb5f9..0000000000 --- a/source/java/org/alfresco/cmis/CMISQueryService.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISRelationshipDirectionEnum.java b/source/java/org/alfresco/cmis/CMISRelationshipDirectionEnum.java deleted file mode 100644 index a6d09d331e..0000000000 --- a/source/java/org/alfresco/cmis/CMISRelationshipDirectionEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISRelationshipDirectionEnum.class, SOURCE); -} \ No newline at end of file diff --git a/source/java/org/alfresco/cmis/CMISRelationshipReference.java b/source/java/org/alfresco/cmis/CMISRelationshipReference.java deleted file mode 100644 index 66e6e1042f..0000000000 --- a/source/java/org/alfresco/cmis/CMISRelationshipReference.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISRendition.java b/source/java/org/alfresco/cmis/CMISRendition.java deleted file mode 100644 index f1565a0f08..0000000000 --- a/source/java/org/alfresco/cmis/CMISRendition.java +++ /dev/null @@ -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 . - */ -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(); - -} diff --git a/source/java/org/alfresco/cmis/CMISRenditionService.java b/source/java/org/alfresco/cmis/CMISRenditionService.java deleted file mode 100644 index 084f57848a..0000000000 --- a/source/java/org/alfresco/cmis/CMISRenditionService.java +++ /dev/null @@ -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 . - */ -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 getRenditions(NodeRef node, String renditionFilter) throws CMISFilterNotValidException; - -} diff --git a/source/java/org/alfresco/cmis/CMISRepositoryReference.java b/source/java/org/alfresco/cmis/CMISRepositoryReference.java deleted file mode 100644 index 33ab800479..0000000000 --- a/source/java/org/alfresco/cmis/CMISRepositoryReference.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISResultSet.java b/source/java/org/alfresco/cmis/CMISResultSet.java deleted file mode 100644 index 71bf8c9b1e..0000000000 --- a/source/java/org/alfresco/cmis/CMISResultSet.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis; - -import org.alfresco.service.cmr.search.ResultSetSPI; - - - -/** - * A CMIS result set - * - * @author andyh - */ -public interface CMISResultSet extends ResultSetSPI -{ - /** - * 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(); - - -} diff --git a/source/java/org/alfresco/cmis/CMISResultSetColumn.java b/source/java/org/alfresco/cmis/CMISResultSetColumn.java deleted file mode 100644 index 512a881187..0000000000 --- a/source/java/org/alfresco/cmis/CMISResultSetColumn.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISResultSetMetaData.java b/source/java/org/alfresco/cmis/CMISResultSetMetaData.java deleted file mode 100644 index 576be7363f..0000000000 --- a/source/java/org/alfresco/cmis/CMISResultSetMetaData.java +++ /dev/null @@ -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 . - */ -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); -} diff --git a/source/java/org/alfresco/cmis/CMISResultSetRow.java b/source/java/org/alfresco/cmis/CMISResultSetRow.java deleted file mode 100644 index 76f1c99845..0000000000 --- a/source/java/org/alfresco/cmis/CMISResultSetRow.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/CMISResultSetSelector.java b/source/java/org/alfresco/cmis/CMISResultSetSelector.java deleted file mode 100644 index ced0042d9c..0000000000 --- a/source/java/org/alfresco/cmis/CMISResultSetSelector.java +++ /dev/null @@ -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 . - */ -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(); - -} diff --git a/source/java/org/alfresco/cmis/CMISRuntimeException.java b/source/java/org/alfresco/cmis/CMISRuntimeException.java deleted file mode 100644 index 37a502837b..0000000000 --- a/source/java/org/alfresco/cmis/CMISRuntimeException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISScope.java b/source/java/org/alfresco/cmis/CMISScope.java deleted file mode 100644 index c743f6870d..0000000000 --- a/source/java/org/alfresco/cmis/CMISScope.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISScope.class); -} diff --git a/source/java/org/alfresco/cmis/CMISServiceException.java b/source/java/org/alfresco/cmis/CMISServiceException.java deleted file mode 100644 index b37213ba66..0000000000 --- a/source/java/org/alfresco/cmis/CMISServiceException.java +++ /dev/null @@ -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 . - */ -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; - } -} diff --git a/source/java/org/alfresco/cmis/CMISServices.java b/source/java/org/alfresco/cmis/CMISServices.java deleted file mode 100644 index 83a8c3947c..0000000000 --- a/source/java/org/alfresco/cmis/CMISServices.java +++ /dev/null @@ -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 . - */ -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 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 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 null 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 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 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 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 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 null 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 aspectsToRemove, Iterable 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 getReadableObject(String objectId, Class 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 true 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 true 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 getObject(String objectId, Class 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 getVersionSeries(String objectId, Class 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 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 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 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 true if content was overwritten - * @throws CMISContentAlreadyExistsException - * if overwrite was false 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 properties, String folderId, List 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 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; - -} diff --git a/source/java/org/alfresco/cmis/CMISStreamNotSupportedException.java b/source/java/org/alfresco/cmis/CMISStreamNotSupportedException.java deleted file mode 100644 index 8952f3a148..0000000000 --- a/source/java/org/alfresco/cmis/CMISStreamNotSupportedException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISTypeDefinition.java b/source/java/org/alfresco/cmis/CMISTypeDefinition.java deleted file mode 100644 index 659975d737..0000000000 --- a/source/java/org/alfresco/cmis/CMISTypeDefinition.java +++ /dev/null @@ -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 . - */ -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 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 getAllowedSourceTypes(); - - /** - * For an association, get the collection of valid target types. For non-associations the collection will be empty. - * - * @return - */ - public Collection getAllowedTargetTypes(); - - /** - * Gets the property definitions for this type (owned and inherited) - * - * @return property definitions - */ - public Map getPropertyDefinitions(); - - /** - * Gets the property definitions owned by this type - * - * @return - */ - public Map getOwnedPropertyDefinitions(); - - /** - * Gets the Action evaluators for this type - * - * @return - */ - public Map> getActionEvaluators(); -} diff --git a/source/java/org/alfresco/cmis/CMISTypeId.java b/source/java/org/alfresco/cmis/CMISTypeId.java deleted file mode 100644 index f3ea43bd1e..0000000000 --- a/source/java/org/alfresco/cmis/CMISTypeId.java +++ /dev/null @@ -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 . - */ -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; - } - -} diff --git a/source/java/org/alfresco/cmis/CMISTypesFilterEnum.java b/source/java/org/alfresco/cmis/CMISTypesFilterEnum.java deleted file mode 100644 index 4305022105..0000000000 --- a/source/java/org/alfresco/cmis/CMISTypesFilterEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISTypesFilterEnum.class, ANY); -} \ No newline at end of file diff --git a/source/java/org/alfresco/cmis/CMISUpdatabilityEnum.java b/source/java/org/alfresco/cmis/CMISUpdatabilityEnum.java deleted file mode 100644 index eab05808b7..0000000000 --- a/source/java/org/alfresco/cmis/CMISUpdatabilityEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISUpdatabilityEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/CMISVersioningException.java b/source/java/org/alfresco/cmis/CMISVersioningException.java deleted file mode 100644 index a325b5bbb8..0000000000 --- a/source/java/org/alfresco/cmis/CMISVersioningException.java +++ /dev/null @@ -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 . - */ -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); - } -} diff --git a/source/java/org/alfresco/cmis/CMISVersioningStateEnum.java b/source/java/org/alfresco/cmis/CMISVersioningStateEnum.java deleted file mode 100644 index fc9bea5bbc..0000000000 --- a/source/java/org/alfresco/cmis/CMISVersioningStateEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory( - CMISVersioningStateEnum.class, null, true); -} diff --git a/source/java/org/alfresco/cmis/PropertyFilter.java b/source/java/org/alfresco/cmis/PropertyFilter.java deleted file mode 100644 index 5015b0104e..0000000000 --- a/source/java/org/alfresco/cmis/PropertyFilter.java +++ /dev/null @@ -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 . - */ -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 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 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 true returns if property is allowed by filter. In other case returns false - */ - public boolean allow(String property) - { - return properties == null || properties.contains(property); - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/cmis/acl/CMISAccessControlEntriesGroupedByPrincipalIdImpl.java b/source/java/org/alfresco/cmis/acl/CMISAccessControlEntriesGroupedByPrincipalIdImpl.java deleted file mode 100644 index 9ecf97c6a8..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISAccessControlEntriesGroupedByPrincipalIdImpl.java +++ /dev/null @@ -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 . - */ -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 directPermissions = new ArrayList(); - - private List indirectPermissions = new ArrayList(); - - /*package */ CMISAccessControlEntriesGroupedByPrincipalIdImpl(String principalId) - { - this.principalId = principalId; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId#getDirectPermissions() - */ - public List getDirectPermissions() - { - return directPermissions; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId#getInirectPermissions() - */ - public List 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()); - } - } - - - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISAccessControlEntryImpl.java b/source/java/org/alfresco/cmis/acl/CMISAccessControlEntryImpl.java deleted file mode 100644 index d3c18c18ed..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISAccessControlEntryImpl.java +++ /dev/null @@ -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 . - */ -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(); - } - - - - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISAccessControlReportImpl.java b/source/java/org/alfresco/cmis/acl/CMISAccessControlReportImpl.java deleted file mode 100644 index f19f59b8c6..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISAccessControlReportImpl.java +++ /dev/null @@ -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 . - */ -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 entries = new ArrayList(); - - private boolean extract = false; - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISAccessControlReport#getAccessControlEntries() - */ - public List 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 getAccessControlEntriesGroupedByPrincipalId() throws CMISConstraintException - { - HashMap grouped = new HashMap(); - 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 answer = new ArrayList(grouped.values()); - return answer; - } - - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISAccessControlServiceImpl.java b/source/java/org/alfresco/cmis/acl/CMISAccessControlServiceImpl.java deleted file mode 100644 index fff11a36e6..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISAccessControlServiceImpl.java +++ /dev/null @@ -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 . - */ -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 acesToApply) throws CMISConstraintException - { - Set acesToAdd = new LinkedHashSet(acesToApply); - List acesExisting = getAcl(nodeRef, - CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS).getAccessControlEntries(); - List acesToRemove = new ArrayList(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(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 acesToRemove, List 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 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 permissions = permissionService.getAllSetPermissions(nodeRef); - ArrayList ordered = new ArrayList(); - 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 longForms = permissionModelDao.getGranteePermissions(permissionReference); - HashSet shortForms = new HashSet(); - for(PermissionReference longForm : longForms) - { - shortForms.add(getPermission(longForm)); - } - for(Pair 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 getPermissionMappings() - { - ArrayList mappings = new ArrayList(); - for(CMISAllowedActionEnum e : EnumSet.allOf(CMISAllowedActionEnum.class)) - { - Map> enumMappings = e.getPermissionMapping(); - for(String key : enumMappings.keySet()) - { - List 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 getRepositoryPermissions() - { - ArrayList answer = new ArrayList(); - PermissionReference allPermission = permissionModelDao.getPermissionReference(null, PermissionService.ALL_PERMISSIONS); - Set 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 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 - { - - /* - * (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())); - } - - } - - } - } - - } - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISAllowedActionKeyTypeEnum.java b/source/java/org/alfresco/cmis/acl/CMISAllowedActionKeyTypeEnum.java deleted file mode 100644 index 9610ffed7b..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISAllowedActionKeyTypeEnum.java +++ /dev/null @@ -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 . - */ -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 FACTORY = new EnumFactory(CMISAllowedActionKeyTypeEnum.class, null, true); - - - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISPermissionDefinitionImpl.java b/source/java/org/alfresco/cmis/acl/CMISPermissionDefinitionImpl.java deleted file mode 100644 index 36ed021fef..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISPermissionDefinitionImpl.java +++ /dev/null @@ -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 . - */ -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; - } - - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISPermissionMappingImpl.java b/source/java/org/alfresco/cmis/acl/CMISPermissionMappingImpl.java deleted file mode 100644 index 521c6da83d..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISPermissionMappingImpl.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.acl; - -import java.util.List; - -import org.alfresco.cmis.CMISPermissionMapping; - -/** - * @author andyh - * - */ -public class CMISPermissionMappingImpl implements CMISPermissionMapping -{ - String key; - - List permissions; - - CMISPermissionMappingImpl(String key, List 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 getPermissions() - { - return permissions; - } - -} diff --git a/source/java/org/alfresco/cmis/acl/CMISPermissionMappingKey.java b/source/java/org/alfresco/cmis/acl/CMISPermissionMappingKey.java deleted file mode 100644 index cd0a8639ce..0000000000 --- a/source/java/org/alfresco/cmis/acl/CMISPermissionMappingKey.java +++ /dev/null @@ -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 . - */ -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(); -} diff --git a/source/java/org/alfresco/cmis/changelog/CMISChangeEventImpl.java b/source/java/org/alfresco/cmis/changelog/CMISChangeEventImpl.java deleted file mode 100644 index bcb3ffa931..0000000000 --- a/source/java/org/alfresco/cmis/changelog/CMISChangeEventImpl.java +++ /dev/null @@ -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 . - */ -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); - } - -} diff --git a/source/java/org/alfresco/cmis/changelog/CMISChangeLogImpl.java b/source/java/org/alfresco/cmis/changelog/CMISChangeLogImpl.java deleted file mode 100644 index 47f4b05e57..0000000000 --- a/source/java/org/alfresco/cmis/changelog/CMISChangeLogImpl.java +++ /dev/null @@ -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 . - */ -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 changeEvents = new LinkedList(); - private String nextChangeToken; - - /** - * @see org.alfresco.cmis.CMISChangeLog#getChangeEvents() - */ - public List getChangeEvents() - { - return changeEvents; - } - - /** - * Set the change events - * - * @param changeEvents list of change events - */ - protected void setChangeEvents(List 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; - } - -} diff --git a/source/java/org/alfresco/cmis/changelog/CMISChangeLogServiceImpl.java b/source/java/org/alfresco/cmis/changelog/CMISChangeLogServiceImpl.java deleted file mode 100644 index 5524ab90d8..0000000000 --- a/source/java/org/alfresco/cmis/changelog/CMISChangeLogServiceImpl.java +++ /dev/null @@ -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 . - */ -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 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 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 changeEvents = result.getChangeEvents(); - EntryIdCallback changeLogCollectingCallback = new EntryIdCallback(true) - { - @Override - public boolean handleAuditEntry(Long entryId, String user, long time, Map values) - { - List 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 getChangesOnTypeCapability() - { - if (null == changesOnTypeCapability) - { - changesOnTypeCapability = new LinkedList(); - } - 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 convertValuesMapToChangeLogEvents(Map values, long time) - { - List result = new ArrayList(); - if (values != null && values.size() > 0) - { - for (Entry 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 valueMap = (Map)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 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 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 values) - { - if (++this.indexWithinPage == this.pageSize) - { - this.indexWithinPage = 0; - return super.handleAuditEntry(entryId, user, time, values); - } - return true; - } - } -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java b/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java deleted file mode 100644 index 883fdb1497..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISAbstractDictionaryService.java +++ /dev/null @@ -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 . - */ -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 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 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 typeDefsByQName = new HashMap(); - Map assocDefsByQName = new HashMap(); - Map objectDefsByTypeId = new HashMap(); - Map typeDefsByTypeId = new HashMap(); - Map typeDefsByQueryName = new HashMap(); - List baseTypes = new ArrayList(); - - // Property Definitions Index - Map propDefsById = new HashMap(); - Map propDefsByQName = new HashMap(); - Map propDefsByPropId = new HashMap(); - Map propDefsByQueryName = new HashMap(); - - /** - * 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 getBaseTypes() - { - return Collections.unmodifiableCollection(getRegistry().baseTypes); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.dictionary.CMISDictionaryService#getAllTypes() - */ - public Collection 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 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 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> order = new TreeMap>(); - 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 classes = order.get(depth); - if (classes == null) - { - classes = new ArrayList(); - 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) - { - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java deleted file mode 100644 index a45c160c2a..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISAbstractTypeDefinition.java +++ /dev/null @@ -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 . - */ -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 subTypeIds = null; - protected Collection subTypes = null; - protected Map properties = null; - protected Map inheritedProperties = null; - protected Map ownedProperties = null; - protected Map> 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 createProperties(CMISMapping cmisMapping, DictionaryService dictionaryService) - { - // map properties directly defined on this type - properties = new HashMap(); - 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(); - Collection 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 ? "" : parentType.getTypeId()) + - ", internal parent=" + (internalParentType == null ? "" : 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(); - 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(); - ownedProperties = new HashMap(); - 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 getSubTypes(boolean includeDescendants) - { - if (!includeDescendants) - { - return subTypes; - } - - // recurse sub-type hierarchy - Collection descendants = new ArrayList(); - LinkedList stack = new LinkedList(); - 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 getPropertyDefinitions() - { - return inheritedProperties; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getOwnedPropertyDefinitions() - */ - public Map getOwnedPropertyDefinitions() - { - return ownedProperties; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISTypeDefinition#getActionEvaluators() - */ - public Map> 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 getAllowedSourceTypes() - { - return Collections.emptyList(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.dictionary.CMISTypeDefinition#getAllowedTargetTypes() - */ - public Collection 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; - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java deleted file mode 100644 index f5b76788d3..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java +++ /dev/null @@ -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 . - */ -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 choices = new HashSet(); - - 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 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(); - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java deleted file mode 100644 index 090ba25a80..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISDocumentTypeDefinition.java +++ /dev/null @@ -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 . - */ -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 ? "" : 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(); - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java deleted file mode 100644 index fb9375c029..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISFolderTypeDefinition.java +++ /dev/null @@ -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 . - */ -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 ? "" : 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(); - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java deleted file mode 100644 index 8179348f50..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISObjectTypeDefinition.java +++ /dev/null @@ -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 . - */ -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(); - Collection 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 ? "" : 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(); - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java deleted file mode 100644 index b527b6bee7..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISPolicyTypeDefinition.java +++ /dev/null @@ -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 . - */ -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(); - if (objectTypeId.equals(CMISDictionaryModel.POLICY_TYPE_ID)) - { - // all aspects are sub-type of POLICY_OBJECT_TYPE - Collection 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(); - ownedProperties = new HashMap(); - // 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 ? "" : 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(); - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java deleted file mode 100644 index 2290f2d912..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISRelationshipTypeDefinition.java +++ /dev/null @@ -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 . - */ -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 allowedSourceTypeIds = new ArrayList(); - private List allowedSourceTypes = new ArrayList(); - private List inheritedAllowedSourceTypes = new ArrayList(); - private List allowedTargetTypeIds = new ArrayList(); - private List allowedTargetTypes = new ArrayList(); - private List inheritedAllowedTargetTypes = new ArrayList(); - - - /** - * 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 createProperties(CMISMapping cmisMapping, DictionaryService dictionaryService) - { - if (objectTypeId.equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID)) - { - return super.createProperties(cmisMapping, dictionaryService); - } - properties = new HashMap(); - 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(); - if (objectTypeId.equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID)) - { - // all associations are sub-type of RELATIONSHIP_OBJECT_TYPE - Collection 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 getAllowedSourceTypes() - { - return inheritedAllowedSourceTypes; - } - - /** - * For an association, get the collection of valid target types. For non-associations the collection will be empty. - * - * @return - */ - public Collection 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 ? "" : 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(); - } - -} diff --git a/source/java/org/alfresco/cmis/dictionary/CMISStrictDictionaryService.java b/source/java/org/alfresco/cmis/dictionary/CMISStrictDictionaryService.java deleted file mode 100644 index d59a39c60b..0000000000 --- a/source/java/org/alfresco/cmis/dictionary/CMISStrictDictionaryService.java +++ /dev/null @@ -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 . - */ -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 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 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); - } - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/AbstractActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/AbstractActionEvaluator.java deleted file mode 100644 index 1b2ad63b40..0000000000 --- a/source/java/org/alfresco/cmis/mapping/AbstractActionEvaluator.java +++ /dev/null @@ -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 . - */ -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 implements CMISActionEvaluator -{ - 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; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/AbstractProperty.java b/source/java/org/alfresco/cmis/mapping/AbstractProperty.java deleted file mode 100644 index 10a717a4fe..0000000000 --- a/source/java/org/alfresco/cmis/mapping/AbstractProperty.java +++ /dev/null @@ -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 . - */ -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 buildLuceneEquality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, - LuceneFunction luceneFunction) throws E - { - return null; - } - - public Q buildLuceneExists(LuceneQueryParserAdaptor lqpa, Boolean not) throws E - { - return null; - } - - public Q buildLuceneGreaterThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, - LuceneFunction luceneFunction) throws E - { - return null; - } - - public Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, - LuceneFunction luceneFunction) throws E - { - return null; - } - - public Q buildLuceneIn(LuceneQueryParserAdaptor lqpa, Collection values, Boolean not, - PredicateMode mode) throws E - { - LuceneQueryParserExpressionAdaptor 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 buildLuceneInequality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, - LuceneFunction luceneFunction) throws E - { - return lqpa.getNegatedQuery(buildLuceneEquality(lqpa, value, mode, luceneFunction)); - } - - public Q buildLuceneLessThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, - LuceneFunction luceneFunction) throws E - { - return null; - } - - public Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, - LuceneFunction luceneFunction) throws E - { - return null; - } - - public Q buildLuceneLike(LuceneQueryParserAdaptor lqpa, Serializable value, Boolean not) throws E - { - return null; - } - - public String getLuceneFieldName() - { - throw new UnsupportedOperationException(); - } - - public String getLuceneSortField(LuceneQueryParserAdaptor 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(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/AbstractSimpleProperty.java b/source/java/org/alfresco/cmis/mapping/AbstractSimpleProperty.java deleted file mode 100644 index 35f09f3c4a..0000000000 --- a/source/java/org/alfresco/cmis/mapping/AbstractSimpleProperty.java +++ /dev/null @@ -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 . - */ -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 buildLuceneEquality(LuceneQueryParserAdaptor 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 buildLuceneExists(LuceneQueryParserAdaptor 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 buildLuceneGreaterThan(LuceneQueryParserAdaptor 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 buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor 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 buildLuceneLessThan(LuceneQueryParserAdaptor 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 buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor 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 buildLuceneLike(LuceneQueryParserAdaptor 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 String getLuceneSortField(LuceneQueryParserAdaptor lqpa) throws E - { - return getLuceneFieldName(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/AbstractVersioningProperty.java b/source/java/org/alfresco/cmis/mapping/AbstractVersioningProperty.java deleted file mode 100644 index f28b994fd3..0000000000 --- a/source/java/org/alfresco/cmis/mapping/AbstractVersioningProperty.java +++ /dev/null @@ -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 . - */ -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 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; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/AspectActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/AspectActionEvaluator.java deleted file mode 100644 index 5e5af6652c..0000000000 --- a/source/java/org/alfresco/cmis/mapping/AspectActionEvaluator.java +++ /dev/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 . - */ -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:
- * - is it expected that aspect(s) had been applied;
- * - should all aspects in the collection satisfying to the specified condition or at least 1 aspect is enough
- *
- * This evaluator is generic, because it is used in the scope of {@link CompositeActionEvaluator} - * - * @author Dmitry Velichkevich - */ -public class AspectActionEvaluator extends AbstractActionEvaluator -{ - 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: true - aspects application is expected, false - aspects absence is expected - * @param allAspectsMustConcur - {@link Boolean} value, which determines: true - all aspects should satisfy expected condition, false - - * at least 1 aspect should satisfy the expected 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; - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/cmis/mapping/BaseTypeIdProperty.java b/source/java/org/alfresco/cmis/mapping/BaseTypeIdProperty.java deleted file mode 100644 index 916c39edda..0000000000 --- a/source/java/org/alfresco/cmis/mapping/BaseTypeIdProperty.java +++ /dev/null @@ -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 . - */ -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 buildLuceneEquality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - return lqpa.getFieldQuery("TYPE", getBaseType(getValueAsString(value)), AnalysisMode.IDENTIFIER, luceneFunction); - } - - @Override - public Q buildLuceneExists(LuceneQueryParserAdaptor 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; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/CMISMapping.java b/source/java/org/alfresco/cmis/mapping/CMISMapping.java deleted file mode 100644 index 583a73d230..0000000000 --- a/source/java/org/alfresco/cmis/mapping/CMISMapping.java +++ /dev/null @@ -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 . - */ -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 CONTENT_STREAM_SUPPORTED_COMPARATOR = new Comparable() - { - @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 mapAlfrescoQNameToTypeId = new HashMap(); - private Map mapCmisQNameToAlfrescoQName = new HashMap(); - private Map mapAlfrescoQNameToCmisQName = new HashMap(); - private Map mapAlfrescoToCmisDataType = new HashMap(); - private Map propertyAccessors = new HashMap(); - private Map>> actionEvaluators = new HashMap>>(); - - - /* - * (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(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT).addPermissionCondition( - PermissionService.DELETE_NODE).addPropertyCondition(PROPERTY_MUTABLE)); - // Depends on cmis:immutable - registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES).addPermissionCondition( - PermissionService.WRITE_PROPERTIES).addAspectCondition(false, Version2Model.ASPECT_VERSION).addPropertyCondition(PROPERTY_MUTABLE)); - registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, DEFAULT_ALLOWING, - PermissionService.READ_PROPERTIES)); - registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, DEFAULT_ALLOWING, - PermissionService.READ_ASSOCIATIONS)); - - registerEvaluator(CMISScope.DOCUMENT, new ParentActionEvaluator(new PermissionActionEvaluator(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(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(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() - { - @Override - public int compareTo(Object another) - { - return CMISContentStreamAllowedEnum.ALLOWED.compareTo((CMISContentStreamAllowedEnum) another); - } - })); - - // Also depends on cmis:immutable - registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator(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(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_CANCEL_CHECKOUT).addPermissionCondition( - PermissionService.CANCEL_CHECK_OUT).addPwcCondition(true)); - registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator(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(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(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ALL_VERSIONS, true)); - // Depends on cmis:immutable - registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator(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(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(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(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false)); - registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, true)); - registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false)); - // Depends on cmis:immutable - registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_RELATIONSHIP) - .addPermissionCondition(PermissionService.CREATE_ASSOCIATIONS).addPropertyCondition(PROPERTY_MUTABLE)); - registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RENDITIONS, true)); - registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, DEFAULT_ALLOWING, - PermissionService.READ_PERMISSIONS)); - // Depends on cmis:immutable - registerEvaluator(CMISScope.DOCUMENT, new CompositeActionEvaluator(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL).addPermissionCondition( - PermissionService.CHANGE_PERMISSIONS).addPropertyCondition(PROPERTY_MUTABLE)); - - registerEvaluator(CMISScope.FOLDER, new RootActionEvaluator(new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, - DEFAULT_ALLOWING, PermissionService.DELETE_NODE), false)); - registerEvaluator(CMISScope.FOLDER, new CompositeActionEvaluator(DEFAULT_ALLOWING, serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES) - .addPermissionCondition(PermissionService.WRITE_PROPERTIES)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_TREE, DEFAULT_ALLOWING, PermissionService.READ_CHILDREN)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, DEFAULT_ALLOWING, PermissionService.READ_PROPERTIES)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, DEFAULT_ALLOWING, - PermissionService.READ_ASSOCIATIONS)); - registerEvaluator(CMISScope.FOLDER, new ParentActionEvaluator(new PermissionActionEvaluator(serviceRegistry, - CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, DEFAULT_ALLOWING, PermissionService.READ_PERMISSIONS))); - registerEvaluator(CMISScope.FOLDER, new ParentActionEvaluator(new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_PARENT, - DEFAULT_ALLOWING, PermissionService.READ_PERMISSIONS))); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_DESCENDANTS, DEFAULT_ALLOWING, - PermissionService.READ_CHILDREN)); - // Is CAN_MOVE_OBJECT correct mapping? - registerEvaluator(CMISScope.FOLDER, new RootActionEvaluator(new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, - DEFAULT_ALLOWING, PermissionService.DELETE_NODE), false)); - registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false)); - registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, true)); - registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_CHILDREN, DEFAULT_ALLOWING, - PermissionService.READ_CHILDREN)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_DOCUMENT, DEFAULT_ALLOWING, - PermissionService.CREATE_CHILDREN)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_FOLDER, DEFAULT_ALLOWING, - PermissionService.CREATE_CHILDREN)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_RELATIONSHIP, DEFAULT_ALLOWING, - PermissionService.CREATE_ASSOCIATIONS)); - registerEvaluator(CMISScope.FOLDER, new RootActionEvaluator(new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_TREE, - DEFAULT_ALLOWING, PermissionService.DELETE_NODE), false)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, DEFAULT_ALLOWING, - PermissionService.READ_PERMISSIONS)); - registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, DEFAULT_ALLOWING, - PermissionService.CHANGE_PERMISSIONS)); - - registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, true)); - registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false)); - registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, true)); - registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false)); - registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false)); - - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_ADD_OBJECT_TO_FOLDER, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false)); - registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(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 /_ - * @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> getActionEvaluators(CMISScope scope) - { - Map> 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 evaluator) - { - Map> evaluators = actionEvaluators.get(scope); - if (evaluators == null) - { - evaluators = new LinkedHashMap>(); - 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> getReportedPermissions(String permission, Set permissions, boolean hasFull, boolean isDirect, CMISAccessControlFormatEnum format) - { - ArrayList> answer = new ArrayList>(20); - // indirect - - if(hasFull) - { - answer.add(new Pair(CMISAccessControlService.CMIS_READ_PERMISSION, false)); - answer.add(new Pair(CMISAccessControlService.CMIS_WRITE_PERMISSION, false)); - answer.add(new Pair(CMISAccessControlService.CMIS_ALL_PERMISSION, false)); - } - - for(String perm : permissions) - { - if(PermissionService.READ.equals(perm)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_READ_PERMISSION, false)); - } - else if(PermissionService.WRITE.equals(perm)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_WRITE_PERMISSION, false)); - } - else if(PermissionService.ALL_PERMISSIONS.equals(perm)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_READ_PERMISSION, false)); - answer.add(new Pair(CMISAccessControlService.CMIS_WRITE_PERMISSION, false)); - answer.add(new Pair(CMISAccessControlService.CMIS_ALL_PERMISSION, false)); - } - - if(hasFull) - { - answer.add(new Pair(CMISAccessControlService.CMIS_READ_PERMISSION, false)); - answer.add(new Pair(CMISAccessControlService.CMIS_WRITE_PERMISSION, false)); - answer.add(new Pair(CMISAccessControlService.CMIS_ALL_PERMISSION, false)); - } - } - - // permission - - if(format == CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS) - { - if(PermissionService.READ.equals(permission)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_READ_PERMISSION, false)); - answer.add(new Pair(permission, isDirect)); - } - else if(PermissionService.WRITE.equals(permission)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_WRITE_PERMISSION, false)); - answer.add(new Pair(permission, isDirect)); - } - else if(PermissionService.ALL_PERMISSIONS.equals(permission)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_ALL_PERMISSION, false)); - answer.add(new Pair(permission, isDirect)); - } - else - { - answer.add(new Pair(permission, isDirect)); - } - } - else if(format == CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS) - { - if(PermissionService.READ.equals(permission)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_READ_PERMISSION, isDirect)); - } - else if(PermissionService.WRITE.equals(permission)) - { - answer.add(new Pair(CMISAccessControlService.CMIS_WRITE_PERMISSION, isDirect)); - } - else if(PermissionService.ALL_PERMISSIONS.equals(permission)) - { - answer.add(new Pair(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; - } - - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java b/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java deleted file mode 100644 index 809d1c0566..0000000000 --- a/source/java/org/alfresco/cmis/mapping/CMISServicesImpl.java +++ /dev/null @@ -1,1995 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.InputStream; -import java.io.Serializable; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.alfresco.cmis.CMISConstraintException; -import org.alfresco.cmis.CMISContentAlreadyExistsException; -import org.alfresco.cmis.CMISContentStreamAllowedEnum; -import org.alfresco.cmis.CMISDataTypeEnum; -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISFilterNotValidException; -import org.alfresco.cmis.CMISInvalidArgumentException; -import org.alfresco.cmis.CMISNotSupportedException; -import org.alfresco.cmis.CMISObjectNotFoundException; -import org.alfresco.cmis.CMISPermissionDeniedException; -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISRelationshipDirectionEnum; -import org.alfresco.cmis.CMISRendition; -import org.alfresco.cmis.CMISRenditionService; -import org.alfresco.cmis.CMISRuntimeException; -import org.alfresco.cmis.CMISScope; -import org.alfresco.cmis.CMISServiceException; -import org.alfresco.cmis.CMISServices; -import org.alfresco.cmis.CMISStreamNotSupportedException; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.cmis.CMISTypesFilterEnum; -import org.alfresco.cmis.CMISUpdatabilityEnum; -import org.alfresco.cmis.CMISVersioningException; -import org.alfresco.cmis.CMISVersioningStateEnum; -import org.alfresco.cmis.PropertyFilter; -import org.alfresco.cmis.dictionary.CMISFolderTypeDefinition; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.query.EmptyPagingResults; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.permissions.AccessDeniedException; -import org.alfresco.repo.tenant.TenantAdminService; -import org.alfresco.repo.tenant.TenantDeployer; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.coci.CheckOutCheckInService; -import org.alfresco.service.cmr.coci.CheckOutCheckInServiceException; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.InvalidAspectException; -import org.alfresco.service.cmr.model.FileExistsException; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.model.FileNotFoundException; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.InvalidNodeRefException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchParameters; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionDoesNotExistException; -import org.alfresco.service.cmr.version.VersionHistory; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.FileFilterMode; -import org.alfresco.util.FileFilterMode.Client; -import org.alfresco.util.Pair; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ApplicationContextEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * CMIS Services Implementation. - * - * @author davidc - * @author dward - */ -public class CMISServicesImpl implements CMISServices, ApplicationContextAware, ApplicationListener, TenantDeployer -{ - private static Log logger = LogFactory.getLog(CMISServicesImpl.class); - - private static final int ASSOC_ID_PREFIX_LENGTH = ASSOC_ID_PREFIX.length(); - - private static final Pattern ORDER_BY_PATTERN = Pattern.compile("^([^\\s,\"'\\\\\\.\\(\\)]+)\\s+(ASC|DESC)$"); - - // dependencies - private Repository repository; - private RetryingTransactionHelper retryingTransactionHelper; - private DictionaryService dictionaryService; - private CMISDictionaryService cmisDictionaryService; - private NamespaceService namespaceService; - private SearchService searchService; - private NodeService nodeService; - private FileFolderService fileFolderService; - private ContentService contentService; - private TenantAdminService tenantAdminService; - private CMISRenditionService cmisRenditionService; - private CheckOutCheckInService checkOutCheckInService; - private VersionService versionService; - private ProcessorLifecycle lifecycle = new ProcessorLifecycle(); - - // CMIS supported version - private String cmisVersion = "[undefined]"; - private String cmisSpecTitle = "[undefined]"; - - // default CMIS store and path - private StoreRef defaultStoreRef; - private String defaultRootPath; - private Map defaultRootNodeRefs; - - // data types for query - @SuppressWarnings("unused") - private DataTypeDefinition nodeRefDataType; - @SuppressWarnings("unused") - private DataTypeDefinition textDataType; - - - /** - * Sets the supported version of the CMIS specification - * - * @param cmisVersion - */ - public void setCMISSpecVersion(String cmisVersion) - { - this.cmisVersion = cmisVersion; - } - - /** - * Sets the CMIS specification title - * - * @param cmisTitle - */ - public void setCMISSpecTitle(String cmisSpecTitle) - { - this.cmisSpecTitle = cmisSpecTitle; - } - - /** - * Sets the default root store - * - * @param store store_type://store_id - */ - public void setDefaultStore(String store) - { - this.defaultStoreRef = new StoreRef(store); - } - - /** - * Sets the default root path - * - * @param path path within default store - */ - public void setDefaultRootPath(String path) - { - defaultRootPath = path; - } - - /** - * Sets the tenant admin service - */ - public void setTenantAdminService(TenantAdminService tenantAdminService) - { - this.tenantAdminService = tenantAdminService; - } - - /** - * Sets helper that provides transaction callbacks - */ - public void setTransactionHelper(RetryingTransactionHelper retryingTransactionHelper) - { - this.retryingTransactionHelper = retryingTransactionHelper; - } - - /** - * @param namespaceService - */ - public void setNamespaceService(NamespaceService namespaceService) - { - this.namespaceService = namespaceService; - } - - /** - * @param dictionaryService - */ - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - /** - * @param cmisDictionaryService - */ - public void setCMISDictionaryService(CMISDictionaryService cmisDictionaryService) - { - this.cmisDictionaryService = cmisDictionaryService; - } - - /** - * @param searchService - */ - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - /** - * @param nodeService - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * @param fileFolderService - */ - public void setFileFolderService(FileFolderService fileFolderService) - { - this.fileFolderService = fileFolderService; - } - - /** - * Sets the content service. - * - * @param contentService - * the content service - */ - public void setContentService(ContentService contentService) - { - this.contentService = contentService; - } - - /** - * Sets the repository. - * - * @param repository - * the repository - */ - public void setRepository(Repository repository) - { - this.repository = repository; - } - - /** - * Sets the cmis rendition service. - * - * @param cmisRenditionService - * the cmis rendition service - */ - public void setCMISRenditionService(CMISRenditionService cmisRenditionService) - { - this.cmisRenditionService = cmisRenditionService; - } - - /** - * Sets the check out check in service. - * - * @param checkOutCheckInService - * the check out check in service - */ - public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService) - { - this.checkOutCheckInService = checkOutCheckInService; - } - - /** - * Sets the version service. - * - * @param versionService - * the version service - */ - public void setVersionService(VersionService versionService) - { - this.versionService = versionService; - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - lifecycle.setApplicationContext(applicationContext); - } - - @Override - public void onApplicationEvent(ApplicationContextEvent event) - { - lifecycle.onApplicationEvent(event); - } - - /** - * Hooks into Spring Application Lifecycle. - */ - private class ProcessorLifecycle extends AbstractLifecycleBean - { - - @Override - protected void onBootstrap(ApplicationEvent event) - { - init(); - } - - @Override - protected void onShutdown(ApplicationEvent event) - { - } - } - - @Override - public void onEnableTenant() - { - init(); - } - - @Override - public void onDisableTenant() - { - destroy(); - } - - @Override - public void init() - { - // initialise data types - nodeRefDataType = dictionaryService.getDataType(DataTypeDefinition.NODE_REF); - textDataType = dictionaryService.getDataType(DataTypeDefinition.TEXT); - - // initialise root node ref - tenantAdminService.register(this); - if (defaultRootNodeRefs == null) - { - defaultRootNodeRefs = new HashMap(1); - } - getDefaultRootNodeRef(); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.tenant.TenantDeployer#destroy() - */ - public void destroy() - { - defaultRootNodeRefs.remove(tenantAdminService.getCurrentUserDomain()); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getCMISVersion() - */ - public String getCMISVersion() - { - return cmisVersion; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getCMISSpecTitle() - */ - public String getCMISSpecTitle() - { - return cmisSpecTitle; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getDefaultRootPath() - */ - public String getDefaultRootPath() - { - return defaultRootPath; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getDefaultRootNodeRef() - */ - public NodeRef getDefaultRootNodeRef() - { - String tenantDomain = tenantAdminService.getCurrentUserDomain(); - NodeRef defaultNodeRef = defaultRootNodeRefs.get(tenantDomain); - if (defaultNodeRef == null) - { - defaultNodeRef = AuthenticationUtil.runAs(new RunAsWork() - { - public NodeRef doWork() throws Exception - { - return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() - { - public NodeRef execute() throws Exception - { - NodeRef root = nodeService.getRootNode(defaultStoreRef); - List rootNodes = searchService.selectNodes(root, defaultRootPath, null, namespaceService, false); - if (rootNodes.size() != 1) - { - throw new AlfrescoRuntimeException("Unable to locate CMIS root path " + defaultRootPath); - } - return rootNodes.get(0); - }; - }, true, false); - } - }, AuthenticationUtil.getSystemUserName()); - - if (defaultNodeRef == null) - { - throw new AlfrescoRuntimeException("Default root folder path '" + defaultRootPath + "' not found"); - } - defaultRootNodeRefs.put(tenantDomain, defaultNodeRef); - } - return defaultNodeRef; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getDefaultRootStoreRef() - */ - public StoreRef getDefaultRootStoreRef() - { - return getDefaultRootNodeRef().getStoreRef(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getNode(java.lang.String, java.lang.String[]) - */ - public NodeRef getNode(String referenceType, String[] reference) - { - NodeRef nodeRef = repository.findNodeRef(referenceType, reference); - return nodeRef; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getRenditions(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public Map getRenditions(NodeRef nodeRef, String renditionFilter) throws CMISFilterNotValidException - { - Map result = new TreeMap(); - List renditions = cmisRenditionService.getRenditions(nodeRef, renditionFilter); - if (renditions == null) - { - renditions = Collections.emptyList(); - } - result.put("node", nodeRef); - result.put("renditionFilter", renditionFilter); // Record rendition filter to aid recursion on node maps - result.put("renditions", renditions); - List renditionNodes = new ArrayList(renditions.size()); - for (CMISRendition rendition : renditions) - { - renditionNodes.add(rendition.getNodeRef()); - } - result.put("renditionNodes", renditionNodes); - return result; - } - - - @Override - public NodeRef[] getChildren(NodeRef folderNodeRef, CMISTypesFilterEnum typesFilter, String orderBy) - throws CMISInvalidArgumentException - { - PagingResults pageOfNodeInfos = getChildren(folderNodeRef, typesFilter, BigInteger.valueOf(Integer.MAX_VALUE), BigInteger.valueOf(0), orderBy); - - List filteredChildren = pageOfNodeInfos.getPage(); - int pageCnt = filteredChildren.size(); - NodeRef[] result = new NodeRef[pageCnt]; - - int idx = 0; - for (FileInfo child : filteredChildren) - { - result[idx] = child.getNodeRef(); - idx++; - } - - return result; - } - - public PagingResults getChildren(NodeRef folderNodeRef, CMISTypesFilterEnum typesFilter, BigInteger maxItems, BigInteger skipCount, String orderBy) - throws CMISInvalidArgumentException - { - if (typesFilter == CMISTypesFilterEnum.POLICIES) - { - return new EmptyPagingResults(); - } - - long start = System.currentTimeMillis(); - - boolean listFiles = (typesFilter != CMISTypesFilterEnum.FOLDERS); - boolean listFolders = (typesFilter != CMISTypesFilterEnum.DOCUMENTS); - - // convert BigIntegers to int - int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue()); - int skip = (skipCount == null || skipCount.intValue() < 0 ? 0 : skipCount.intValue()); - - // convert orderBy to sortProps - List> sortProps = null; - if (orderBy != null) - { - sortProps = new ArrayList>(1); - - String[] parts = orderBy.split(","); - int len = parts.length; - final int origLen = len; - - if (origLen > 0) - { - int maxSortProps = GetChildrenCannedQuery.MAX_FILTER_SORT_PROPS; - if (len > maxSortProps) - { - if (logger.isDebugEnabled()) - { - logger.debug("Too many sort properties in 'orderBy' - ignore those above max (max=" - + maxSortProps + ",actual=" + len + ")"); - } - len = maxSortProps; - } - for (int i = 0; i < len; i++) - { - String[] sort = parts[i].split(" +"); - - if (sort.length > 0) - { - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(sort[0]); - if (propDef != null) - { - QName sortProp = null; - if (propDef.getPropertyId().getId().equals(CMISDictionaryModel.PROP_BASE_TYPE_ID)) - { - // special-case (see also ALF-13968) - for getChildren, using "cmis:baseTypeId" allows sorting of folders first and vice-versa (cmis:folder <-> cmis:document) - sortProp = GetChildrenCannedQuery.SORT_QNAME_NODE_IS_FOLDER; - } - else - { - sortProp = propDef.getPropertyAccessor().getMappedProperty(); - } - - if (sortProp != null) - { - boolean sortAsc = (sort.length == 1) || sort[1].equalsIgnoreCase("asc"); - sortProps.add(new Pair(sortProp, sortAsc)); - } else - { - if (logger.isDebugEnabled()) - { - logger.debug("Ignore sort property '" + sort[0] + " - mapping not found"); - } - } - } else - { - if (logger.isDebugEnabled()) - { - logger.debug("Ignore sort property '" + sort[0] + " - query name not found"); - } - } - } - } - } - - if (sortProps.size() < origLen) - { - logger.warn("Sort properties trimmed - either too many and/or not found: \n" + " orig: " + orderBy - + "\n" + " final: " + sortProps); - } - } - - PagingRequest pageRequest = new PagingRequest(skip, max, null); - pageRequest.setRequestTotalCountMax(skip + 10000); // TODO make this - // optional/configurable - // - affects whether - // numItems may be - // returned - - FileFilterMode.setClient(Client.cmis); - try - { - PagingResults result = fileFolderService.list(folderNodeRef, listFiles, listFolders, null, sortProps, pageRequest); - - if (logger.isDebugEnabled()) - { - logger.debug("getChildren: " + result.getPage().size() + " in " + (System.currentTimeMillis() - start) + " msecs"); - } - - return result; - } - finally - { - FileFilterMode.clearClient(); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getCheckedOut(java.lang.String, org.alfresco.service.cmr.repository.NodeRef, - * boolean, java.lang.String) - */ - public NodeRef[] getCheckedOut(String username, NodeRef folder, boolean includeDescendants, String orderBy) - throws CMISInvalidArgumentException - { - SearchParameters params = new SearchParameters(); - params.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); - - if (folder == null) - { - params.setQuery("+=cm:workingCopyOwner:\""+username+"\""); - params.addStore(folder.getStoreRef()); - } - else - { - // get all checked-out items within folder - // NOTE: special-case for all descendants in root folder (treat as all checked-out items) - if (includeDescendants && nodeService.getRootNode(folder.getStoreRef()) == folder) - { - // get all checked-out items within specified folder store - params.setQuery("+=cm:workingCopyOwner:\""+username+"\""); - params.addStore(folder.getStoreRef()); - } - else - { - params.setQuery("+=cm:workingCopyOwner:\""+username+"\" AND +=PARENT:\""+folder.toString()+"\""); - params.addStore(folder.getStoreRef()); - } - } - parseOrderBy(orderBy, params); - - ResultSet resultSet = null; - try - { - resultSet = searchService.query(params); - List results = resultSet.getNodeRefs(); - NodeRef[] nodeRefs = new NodeRef[results.size()]; - return results.toArray(nodeRefs); - } - finally - { - if (resultSet != null) resultSet.close(); - } - } - - /** - * Parses an order by clause and adds its orderings to the given search parameters. - * - * @param orderBy - * the order by clause - * @param params - * the search parameters - * @throws CMISInvalidArgumentException - * if the order by clause is invalid - */ - private void parseOrderBy(String orderBy, SearchParameters params) throws CMISInvalidArgumentException - { - if (orderBy == null) - { - return; - } - for (String token : orderBy.split(",")) - { - Matcher matcher = ORDER_BY_PATTERN.matcher(token); - if (!matcher.matches()) - { - throw new CMISInvalidArgumentException("Invalid order by clause: \"" + orderBy + '"'); - } - String queryName = matcher.group(1); - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(queryName); - if (propDef == null) - { - throw new CMISInvalidArgumentException("No such property: \"" + queryName + '"'); - } - // We can only order by orderable properties - if (propDef.isOrderable()) - { - params.addSort(propDef.getPropertyLuceneBuilder().getLuceneFieldName(), matcher.group(2).equals("ASC")); - } - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getRelationships(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.cmis.CMISTypeId, boolean, org.alfresco.cmis.CMISRelationshipDirectionEnum) - */ - public AssociationRef[] getRelationships(NodeRef node, CMISTypeDefinition relDef, boolean includeSubTypes, CMISRelationshipDirectionEnum direction) - throws CMISInvalidArgumentException - { - // by the spec. if typeId=null then it is necessary return ALL associated Relationship objects! - // establish relationship type to filter on - if (relDef == null) - { - relDef = cmisDictionaryService.findType(CMISDictionaryModel.RELATIONSHIP_TYPE_ID); - } - if (!relDef.getBaseType().getTypeId().equals(CMISDictionaryModel.RELATIONSHIP_TYPE_ID)) - { - throw new AlfrescoRuntimeException("Type Id " + relDef.getTypeId() + " is not a relationship type"); - } - - // retrieve associations - List assocs = new ArrayList(); - if (direction == CMISRelationshipDirectionEnum.SOURCE || direction == CMISRelationshipDirectionEnum.EITHER) - { - assocs.addAll(nodeService.getTargetAssocs(node, RegexQNamePattern.MATCH_ALL)); - } - if (direction == CMISRelationshipDirectionEnum.TARGET || direction == CMISRelationshipDirectionEnum.EITHER) - { - try - { - assocs.addAll(nodeService.getSourceAssocs(node, RegexQNamePattern.MATCH_ALL)); - } - catch (UnsupportedOperationException uoe) { - // NodeServiceImpl#getSourceAssocs - This operation is not supported for a version store - } - } - - // filter association by type - // NOTE: even if typeId = null, we still filter out relationships that do not map to CMIS domain model e.g. - // relationships whose source or target are not folders or documents - Collection subRelDefs = (includeSubTypes ? relDef.getSubTypes(true) : null); - List filteredAssocs = new ArrayList(assocs.size()); - for (AssociationRef assoc : assocs) - { - CMISTypeDefinition assocTypeDef = cmisDictionaryService.findTypeForClass(assoc.getTypeQName(), CMISScope.RELATIONSHIP); - QName sourceTypeDef = nodeService.getType(assoc.getSourceRef()); - QName targetTypeDef = nodeService.getType(assoc.getTargetRef()); - if (assocTypeDef == null || cmisDictionaryService.findTypeForClass(sourceTypeDef) == null || - cmisDictionaryService.findTypeForClass(targetTypeDef) == null) - { - continue; - } - if (assocTypeDef.equals(relDef) || (subRelDefs != null && subRelDefs.contains(assocTypeDef))) - { - filteredAssocs.add(assoc); - } - } - - AssociationRef[] assocArray = new AssociationRef[filteredAssocs.size()]; - filteredAssocs.toArray(assocArray); - return assocArray; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getProperty(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public Serializable getProperty(NodeRef nodeRef, String propertyName) throws CMISInvalidArgumentException - { - return getProperty(nodeRef, getTypeDefinition(nodeRef), propertyName); - } - - public Serializable getProperty(NodeRef nodeRef, CMISTypeDefinition typeDef, String propertyName) - throws CMISInvalidArgumentException - { - CMISPropertyDefinition propDef = cmisDictionaryService.findProperty(propertyName, typeDef); - if (propDef == null) - { - if (typeDef == null) - { - throw new CMISInvalidArgumentException("Property " + propertyName + " not found in CMIS Dictionary"); - } - else - { - throw new CMISInvalidArgumentException("Property " + propertyName + " not found for type " - + typeDef.getTypeId() + " in CMIS Dictionary"); - } - } - return propDef.getPropertyAccessor().getValue(nodeRef); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getTypeDefinition(org.alfresco.service.cmr.repository.NodeRef) - */ - public CMISTypeDefinition getTypeDefinition(NodeRef nodeRef) throws CMISInvalidArgumentException - { - QName typeQName = nodeService.getType(nodeRef); - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName); - if (typeDef == null) - { - throw new CMISInvalidArgumentException("Type " + typeQName + " not found in CMIS Dictionary"); - } - return typeDef; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getTypeDefinition(org.alfresco.service.cmr.repository.AssociationRef) - */ - public CMISTypeDefinition getTypeDefinition(AssociationRef associationRef) throws CMISInvalidArgumentException - { - QName typeQName = associationRef.getTypeQName(); - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(typeQName, CMISScope.RELATIONSHIP); - if (typeDef == null) - { - throw new CMISInvalidArgumentException("Association Type " + typeQName + " not found in CMIS Dictionary"); - } - return typeDef; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getTypeDefinition(java.lang.String) - */ - public CMISTypeDefinition getTypeDefinition(String typeId) throws CMISInvalidArgumentException - { - CMISTypeDefinition typeDef = null; - try - { - typeDef = cmisDictionaryService.findType(typeId); - } - catch (Exception e) - { - } - if (typeDef == null) - { - throw new CMISInvalidArgumentException("Invalid typeId " + typeId); - } - return typeDef; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getTypeDefinition(java.lang.Object) - */ - public CMISTypeDefinition getTypeDefinition(Object object) throws CMISInvalidArgumentException - { - if (object instanceof Version) - { - return getTypeDefinition(((Version) object).getFrozenStateNodeRef()); - } - else if (object instanceof NodeRef) - { - return getTypeDefinition((NodeRef) object); - } - else if (object instanceof AssociationRef) - { - return getTypeDefinition((AssociationRef) object); - } - throw new CMISInvalidArgumentException("Invalid type " + object.getClass()); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getBaseTypes() - */ - public Collection getBaseTypes() - { - return cmisDictionaryService.getBaseTypes(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getProperty(org.alfresco.service.cmr.repository.AssociationRef, - * java.lang.String) - */ - public Serializable getProperty(AssociationRef assocRef, String propertyName) throws CMISInvalidArgumentException - { - CMISTypeDefinition typeDef = getTypeDefinition(assocRef); - CMISPropertyDefinition propDef = cmisDictionaryService.findProperty(propertyName, typeDef); - if (propDef == null) - { - throw new AlfrescoRuntimeException("Property " + propertyName + " not found for relationship type " - + typeDef.getTypeId() + " in CMIS Dictionary"); - } - return propDef.getPropertyAccessor().getValue(assocRef); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getProperties(org.alfresco.service.cmr.repository.NodeRef) - */ - public Map getProperties(NodeRef nodeRef) throws CMISInvalidArgumentException - { - return getProperties(nodeRef, getTypeDefinition(nodeRef)); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getProperties(org.alfresco.service.cmr.repository.AssociationRef) - */ - public Map getProperties(AssociationRef assocRef) throws CMISInvalidArgumentException - { - CMISTypeDefinition typeDef = getTypeDefinition(assocRef); - Map propDefs = typeDef.getPropertyDefinitions(); - Map values = new HashMap(propDefs.size() * 2); - for (CMISPropertyDefinition propDef : propDefs.values()) - { - values.put(propDef.getPropertyId().getId(), propDef.getPropertyAccessor().getValue(assocRef)); - } - return values; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getProperties(org.alfresco.service.cmr.repository.NodeRef, - * org.alfresco.cmis.CMISTypeDefinition) - */ - public Map getProperties(NodeRef nodeRef, CMISTypeDefinition typeDef) - throws CMISInvalidArgumentException - { - Map propDefs = typeDef.getPropertyDefinitions(); - Map values = new HashMap(propDefs.size() * 2); - for (CMISPropertyDefinition propDef : propDefs.values()) - { - values.put(propDef.getPropertyId().getId(), propDef.getPropertyAccessor().getValue(nodeRef)); - } - return values; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getAspects(org.alfresco.service.cmr.repository.NodeRef) - */ - public Set getAspects(NodeRef nodeRef) - { - Set aspects = nodeService.getAspects(nodeRef); - Set result = new HashSet(aspects.size() * 2); - for (QName aspect : aspects) - { - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(aspect, CMISScope.POLICY); - if (typeDef != null) - { - result.add(typeDef); - } - } - return result; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#setProperty(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.io.Serializable) - */ - public void setProperty(NodeRef nodeRef, String propertyName, Serializable value) - throws CMISInvalidArgumentException, CMISConstraintException - { - setProperty(nodeRef, getTypeDefinition(nodeRef), propertyName, value); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#setProperty(org.alfresco.service.cmr.repository.NodeRef, - * org.alfresco.cmis.CMISTypeDefinition, java.lang.String, java.io.Serializable) - */ - public void setProperty(NodeRef nodeRef, CMISTypeDefinition typeDef, String propertyName, Serializable value) - throws CMISInvalidArgumentException, CMISConstraintException - { - CMISPropertyDefinition propDef = cmisDictionaryService.findProperty(propertyName, typeDef); - if (propDef == null) - { - if (typeDef == null) - { - throw new CMISInvalidArgumentException("Property " + propertyName + " not found in CMIS Dictionary"); - } - else - { - throw new CMISInvalidArgumentException("Property " + propertyName + " not found for type " - + typeDef.getTypeId() + " in CMIS Dictionary"); - } - } - - CMISUpdatabilityEnum updatability = propDef.getUpdatability(); - if (updatability == CMISUpdatabilityEnum.READ_ONLY - || updatability == CMISUpdatabilityEnum.READ_AND_WRITE_WHEN_CHECKED_OUT - && !nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) - { - throw new CMISConstraintException("Unable to update read-only property " + propertyName); - } - - if (propDef.isRequired() && value == null) - { - throw new CMISConstraintException("Property " + propertyName + " is required"); - } - - if (propDef.getDataType() == CMISDataTypeEnum.STRING && propDef.getMaximumLength() > 0 && value != null - && value.toString().length() > propDef.getMaximumLength()) - { - throw new CMISConstraintException("Value is too long for property " + propertyName); - } - - QName property = propDef.getPropertyAccessor().getMappedProperty(); - if (property == null) - { - throw new CMISConstraintException("Unable to set property " + propertyName); - } - - if (property.equals(ContentModel.PROP_NAME)) - { - try - { - fileFolderService.rename(nodeRef, value.toString()); - } - catch (FileExistsException e) - { - throw new CMISConstraintException("Object already exists with name " + value.toString()); - } - catch (FileNotFoundException e) - { - throw new CMISInvalidArgumentException("Object with id " + nodeRef.toString() + " not found"); - } - } - else - { - nodeService.setProperty(nodeRef, property, value); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#setAspects(org.alfresco.service.cmr.repository.NodeRef, java.lang.Iterable, - * java.lang.Iterable) - */ - public void setAspects(NodeRef node, Iterable aspectsToRemove, Iterable aspectsToAdd) - throws CMISInvalidArgumentException - { - for (String aspectType : aspectsToRemove) - { - try - { - nodeService.removeAspect(node, getTypeDefinition(aspectType).getTypeId().getQName()); - } - catch (InvalidAspectException e) - { - throw new CMISInvalidArgumentException("Invalid aspect " + aspectType); - } - catch (InvalidNodeRefException e) - { - throw new CMISInvalidArgumentException("Invalid node " + node); - } - } - for (String aspectType : aspectsToAdd) - { - try - { - nodeService.addAspect(node, getTypeDefinition(aspectType).getTypeId().getQName(), Collections - . emptyMap()); - } - catch (InvalidAspectException e) - { - throw new CMISInvalidArgumentException("Invalid aspect " + aspectType); - } - catch (InvalidNodeRefException e) - { - throw new CMISInvalidArgumentException("Invalid node " + node); - } - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#applyVersioningState(org.alfresco.service.cmr.repository.NodeRef, - * org.alfresco.cmis.CMISVersioningStateEnum) - */ - public NodeRef applyVersioningState(NodeRef source, CMISVersioningStateEnum versioningState) - throws CMISConstraintException, CMISInvalidArgumentException - { - switch (versioningState) - { - case NONE: - return source; - case CHECKED_OUT: - validateVersionable(source); - if (this.nodeService.hasAspect(source, ContentModel.ASPECT_VERSIONABLE) == false) - { - Map props = new HashMap(); - props.put(ContentModel.PROP_INITIAL_VERSION, false); - props.put(ContentModel.PROP_AUTO_VERSION, false); - this.nodeService.addAspect(source, ContentModel.ASPECT_VERSIONABLE, props); - } - return this.checkOutCheckInService.checkout(source); - default: - validateVersionable(source); - this.versionService.createVersion(source, createVersionProperties("Initial Version", - versioningState != CMISVersioningStateEnum.MINOR)); - break; - } - return source; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#checkOut(java.lang.String) - */ - public NodeRef checkOut(String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef nodeRef = getObject(objectId, NodeRef.class, true, true, false); - try - { - return this.checkOutCheckInService.checkout(nodeRef); - } - catch (CheckOutCheckInServiceException e) - { - throw new CMISVersioningException(e.getMessage(), e); - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#checkIn(java.lang.String, java.lang.String, boolean) - */ - public NodeRef checkIn(String objectId, String checkinComment, boolean isMajor) throws CMISConstraintException, - CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException, - CMISPermissionDeniedException - { - NodeRef nodeRef = getObject(objectId, NodeRef.class, true, true, true); - try - { - if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == false) - { - Map props = new HashMap(); - props.put(ContentModel.PROP_INITIAL_VERSION, false); - props.put(ContentModel.PROP_AUTO_VERSION, false); - this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props); - } - return checkOutCheckInService.checkin(nodeRef, createVersionProperties(checkinComment, isMajor)); - } - catch (CheckOutCheckInServiceException e) - { - throw new CMISVersioningException(e.getMessage(), e); - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#cancelCheckOut(java.lang.String) - */ - public void cancelCheckOut(String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef nodeRef = getObject(objectId, NodeRef.class, true, true, true); - try - { - checkOutCheckInService.cancelCheckout(nodeRef); - } - catch (CheckOutCheckInServiceException e) - { - throw new CMISVersioningException(e.getMessage(), e); - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getAllVersions(java.lang.String) - */ - public List getAllVersions(String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef nodeRef = getVersionSeries(objectId, NodeRef.class, true); - - List objects = new LinkedList(); - NodeRef pwc = checkOutCheckInService.getWorkingCopy(nodeRef); - if (pwc != null) - { - objects.add(pwc); - } - VersionHistory versionHistory = versionService.getVersionHistory(nodeRef); - if (versionHistory != null) - { - Version current = versionService.getCurrentVersion(nodeRef); - while (current != null) - { - objects.add(current.getFrozenStateNodeRef()); - current = versionHistory.getPredecessor(current); - } - } - else if (pwc == null) - { - objects.add(nodeRef); - } - return objects; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getObject(java.lang.String, java.lang.Class, boolean, boolean, boolean) - */ - @SuppressWarnings("unchecked") - public T getObject(String objectId, Class requiredType, boolean forUpdate, boolean isVersionable, - boolean isPwc) throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException, - CMISInvalidArgumentException, CMISPermissionDeniedException - { - try - { - int sepIndex = objectId.lastIndexOf(';'); - String nodeRefString; - // Handle version format IDs - if (sepIndex != -1 && NodeRef.isNodeRef(nodeRefString = objectId.substring(0, sepIndex))) - { - if (isPwc) - { - throw new CMISVersioningException(objectId + " is not a working copy"); - } - - // Allow returning of non-updateable version nodes as noderefs - if (requiredType.isAssignableFrom(Version.class) || !forUpdate - && requiredType.isAssignableFrom(NodeRef.class)) - { - NodeRef nodeRef = new NodeRef(nodeRefString); - if (!nodeService.exists(nodeRef)) - { - throw new CMISObjectNotFoundException("Unable to find object " + objectId); - } - VersionHistory versionHistory = versionService.getVersionHistory(nodeRef); - if (versionHistory == null) - { - throw new CMISObjectNotFoundException("Unable to find object " + objectId); - } - try - { - Version version = versionHistory.getVersion(objectId.substring(sepIndex + 1)); - - // Return as noderef if required - return requiredType.isAssignableFrom(Version.class) ? (T) version : (T) version - .getFrozenStateNodeRef(); - } - catch (VersionDoesNotExistException e) - { - throw new CMISObjectNotFoundException("Unable to find object " + objectId); - } - } - else if (requiredType.isAssignableFrom(NodeRef.class)) - { - // We wanted an updateable node but got a history node - throw new CMISVersioningException(objectId + " is not a current node"); - } - } - // Handle node format IDs - else if (NodeRef.isNodeRef(objectId)) - { - if (requiredType.isAssignableFrom(NodeRef.class)) - { - NodeRef nodeRef = new NodeRef(objectId); - if (!nodeService.exists(nodeRef)) - { - throw new CMISObjectNotFoundException("Unable to find object " + objectId); - } - if (isVersionable) - { - validateVersionable(nodeRef); - - // Check that the PWC status is as we require - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) - { - // This is a PWC so make sure we wanted one - if (!isPwc) - { - throw new CMISVersioningException(objectId + " is a working copy"); - } - } - else - { - // This is not a PWC so make sure we didn't want one - if (isPwc) - { - throw new CMISVersioningException(objectId + " is not a working copy"); - } - - // If it should be updateable, make sure it's not currently checked out - if (forUpdate) - { - if (checkOutCheckInService.getWorkingCopy(nodeRef) != null) - { - throw new CMISVersioningException("Can't update " + objectId + " while checked out"); - } - } - } - } - return (T) new NodeRef(objectId); - } - } - // Handle Assoc IDs - else if (objectId.startsWith(ASSOC_ID_PREFIX)) - { - if (isPwc) - { - throw new CMISVersioningException(objectId + " is not a working copy"); - } - if (isVersionable) - { - throw new CMISConstraintException("Type " + CMISDictionaryModel.RELATIONSHIP_TYPE_ID - + " is not versionable"); - } - if (requiredType.isAssignableFrom(AssociationRef.class)) - { - AssociationRef associationRef = nodeService.getAssoc(new Long(objectId.substring(ASSOC_ID_PREFIX_LENGTH))); - if (associationRef == null) - { - throw new CMISObjectNotFoundException("Unable to find object " + objectId); - } - return (T) associationRef; - } - } - else - { - throw new CMISInvalidArgumentException(objectId + " is not an object ID"); - } - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e); - } - throw new CMISConstraintException("Object " + objectId + " is not of required type"); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getReadableObject(java.lang.String, java.lang.Class) - */ - public T getReadableObject(String objectId, Class requiredType) throws CMISConstraintException, - CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException, - CMISPermissionDeniedException - { - return getObject(objectId, requiredType, false, false, false); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getFolder(java.lang.String) - */ - public NodeRef getFolder(String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef folderRef = getReadableObject(objectId, NodeRef.class); - CMISTypeDefinition typeDef = getTypeDefinition(folderRef); - if (typeDef.getTypeId().getBaseTypeId() != CMISDictionaryModel.FOLDER_TYPE_ID) - { - throw new CMISInvalidArgumentException("Object " + objectId + " is not a folder"); - } - return folderRef; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getFolderParent(java.lang.String) - */ - public NodeRef getFolderParent(String folderId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef folderRef = getFolder(folderId); - if (getDefaultRootNodeRef().equals(folderRef)) - { - throw new CMISInvalidArgumentException("Root Folder has no parents"); - } - return nodeService.getPrimaryParent(folderRef).getParentRef(); - } - - @SuppressWarnings("unchecked") - @Override - public T getVersionSeries(String objectId, Class requiredType, boolean isVersionable) - throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException, - CMISInvalidArgumentException, CMISPermissionDeniedException - { - // Preserve non-node objects - if (!requiredType.isAssignableFrom(NodeRef.class)) - { - return getObject(objectId, requiredType, false, isVersionable, false); - } - - Object object = getReadableObject(objectId, Object.class); - Object result; - // Map version nodes back to their source node - if (object instanceof Version) - { - result = ((Version) object).getVersionedNodeRef(); - } - else if (object instanceof NodeRef) - { - NodeRef nodeRef = (NodeRef) object; - // Map working copy nodes back to where they were checked out from - NodeRef workingCopyNodeRef = checkOutCheckInService.getCheckedOut(nodeRef); - if (workingCopyNodeRef != null) - { - // It is a working copy - result = workingCopyNodeRef; - } - else // Preserve all other nodes - { - result = nodeRef; - } - if (isVersionable) - { - validateVersionable((NodeRef)result); - } - } - else if (requiredType.isAssignableFrom(object.getClass())) - { - if (isVersionable) - { - throw new CMISConstraintException(objectId + " is not versionable"); - } - result = object; - } - else - { - throw new CMISConstraintException("Object " + objectId + " is not of required type"); - } - return (T)result; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getLatestVersion(java.lang.String, boolean) - */ - public NodeRef getLatestVersion(String objectId, boolean major) throws CMISConstraintException, - CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException, - CMISPermissionDeniedException - { - NodeRef versionSeries = getVersionSeries(objectId, NodeRef.class, false); - // If we don't care whether the latest version is major or minor, the latest version is either the working copy - // or the live node - if (!major) - { - NodeRef nodeRef = checkOutCheckInService.getWorkingCopy(versionSeries); - if (nodeRef != null) - { - return nodeRef; - } - - return versionSeries; - } - - // Now check the version history - VersionHistory versionHistory = versionService.getVersionHistory(versionSeries); - if (versionHistory == null) - { - throw new CMISObjectNotFoundException(objectId + " has no major version"); - } - Version current = versionService.getCurrentVersion(versionSeries); - while (current != null && current.getVersionType() != VersionType.MAJOR) - { - current = versionHistory.getPredecessor(current); - } - if (current == null) - { - throw new CMISObjectNotFoundException(objectId + " has no major version"); - } - return current.getFrozenStateNodeRef(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#deleteContentStream(java.lang.String) - */ - public void deleteContentStream(String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef currentNode = getObject(objectId, NodeRef.class, true, false, false); - CMISTypeDefinition typeDef = getTypeDefinition(currentNode); - if (CMISContentStreamAllowedEnum.REQUIRED.equals(typeDef.getContentStreamAllowed())) - { - throw new CMISConstraintException( - "The 'contentStreamAllowed' attribute of the specified Object-Type definition is set to 'required'."); - } - - try - { - nodeService.setProperty(currentNode, ContentModel.PROP_CONTENT, null); - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#deleteObject(java.lang.String, boolean) - */ - public void deleteObject(String objectId, boolean allVersions) throws CMISConstraintException, - CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException, - CMISPermissionDeniedException, CMISRuntimeException, CMISServiceException - { - try - { - Object object = allVersions ? getVersionSeries(objectId, Object.class, false) : getObject(objectId, Object.class, true, false, - false); - - // Handle associations - if (object instanceof AssociationRef) - { - AssociationRef assocRef = (AssociationRef) object; - nodeService - .removeAssociation(assocRef.getSourceRef(), assocRef.getTargetRef(), assocRef.getTypeQName()); - return; - } - - // Handle individual versions - if (object instanceof Version) - { - Version version = (Version) object; - versionService.deleteVersion(version.getVersionedNodeRef(), version); - return; - } - NodeRef nodeRef = (NodeRef) object; - - // Handle a working copy - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) - { - checkOutCheckInService.cancelCheckout(nodeRef); - return; - } - - // Handle 'real' nodes - CMISTypeDefinition typeDef = getTypeDefinition(nodeRef); - if (typeDef.getTypeId().getBaseTypeId() == CMISDictionaryModel.FOLDER_TYPE_ID) - { - if (nodeService.getChildAssocs( - nodeRef, - ContentModel.ASSOC_CONTAINS, - RegexQNamePattern.MATCH_ALL, 1, false).size() > 0) - { - throw new CMISConstraintException("Could not delete folder with at least one Child"); - } - } - // Only honour the allVersions flag for non-folder versionable objects - else if (typeDef.isVersionable() && allVersions) - { - NodeRef workingCopy = checkOutCheckInService.getWorkingCopy(nodeRef); - if (workingCopy != null) - { - checkOutCheckInService.cancelCheckout(workingCopy); - } - versionService.deleteVersionHistory(nodeRef); - } - - // Attempt to delete the node - nodeService.deleteNode(nodeRef); - } - catch (CMISServiceException e) - { - throw e; - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e); - } - catch (Exception e) - { - throw new CMISRuntimeException(e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#deleteTree(java.lang.String, boolean, boolean, boolean) - */ - public List deleteTree(String objectId, boolean continueOnFailure, boolean unfile, boolean deleteAllVersions) - throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException, - CMISInvalidArgumentException, CMISPermissionDeniedException - { - NodeRef folderRef = getFolder(objectId); - List failedToDelete = new LinkedList(); - deleteTree(nodeService.getPrimaryParent(folderRef), continueOnFailure, unfile, deleteAllVersions, - failedToDelete); - return failedToDelete; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#deleteTreeReportLastError(java.lang.String, boolean, boolean, boolean) - */ - public void deleteTreeReportLastError(String objectId, boolean continueOnFailure, boolean unfile, - boolean deleteAllVersions) throws CMISServiceException - { - NodeRef folderRef = getFolder(objectId); - List failedToDelete = new LinkedList(); - CMISServiceException lastError = deleteTree(nodeService.getPrimaryParent(folderRef), continueOnFailure, unfile, - deleteAllVersions, failedToDelete); - if (lastError != null) - { - throw lastError; - } - } - - /** - * Internal recursive helper method for tree deletion. Returns the last error encountered, rather than throwing it, - * to avoid transaction rollback. - * - * @param parentRef - * the parent folder - * @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? - * @param failedToDelete - * list of object IDs of the children we failed to delete - * @return the last error encountered. - * @throws CMISInvalidArgumentException - * the CMIS invalid argument exception - */ - private CMISServiceException deleteTree(ChildAssociationRef parentRef, boolean continueOnFailure, boolean unfile, - boolean deleteAllVersions, List failedToDelete) throws CMISInvalidArgumentException - { - CMISServiceException lastError = null; - NodeRef child = parentRef.getChildRef(); - - // Due to multi-filing, it could be that a sub-tree has already been deleted - if (!nodeService.exists(child)) - { - return lastError; - } - - String objectId = (String) getProperty(child, CMISDictionaryModel.PROP_OBJECT_ID); - - // First Delete children - for (ChildAssociationRef childRef : nodeService.getChildAssocs(child)) - { - CMISServiceException thisError = deleteTree(childRef, continueOnFailure, unfile, deleteAllVersions, - failedToDelete); - if (thisError != null) - { - lastError = thisError; - if (!continueOnFailure) - { - return lastError; - } - } - } - - // Don't try deleting the parent if we couldn't delete one or more of its children - if (lastError != null) - { - failedToDelete.add(objectId); - return lastError; - } - - // Now delete the parent - try - { - if (unfile && !parentRef.isPrimary()) - { - this.nodeService.removeChildAssociation(parentRef); - } - else - { - deleteObject(objectId, deleteAllVersions); - } - } - catch (AccessDeniedException t) - { - failedToDelete.add(objectId); - lastError = new CMISPermissionDeniedException(t); - } - catch (Throwable t) - { - // Before absorbing an exception, check whether it is a transactional one that should be retried further up - // the stack - if (RetryingTransactionHelper.extractRetryCause(t) != null) - { - throw new AlfrescoRuntimeException("Transactional Error", t); - } - failedToDelete.add(objectId); - lastError = t instanceof CMISServiceException ? (CMISServiceException) t : new CMISRuntimeException(t); - } - - return lastError; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#addObjectToFolder(java.lang.String, java.lang.String) - */ - public void addObjectToFolder(String objectId, String folderId) throws CMISConstraintException, - CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException, - CMISPermissionDeniedException - { - try - { - NodeRef objectNodeRef = getObject(objectId, NodeRef.class, true, false, false); - NodeRef parentFolderNodeRef = getFolder(folderId); - CMISTypeDefinition objectType = getTypeDefinition(objectNodeRef); - CMISTypeDefinition folderType = getTypeDefinition(parentFolderNodeRef); - if (!folderType.getAllowedTargetTypes().isEmpty() - && !folderType.getAllowedTargetTypes().contains(objectType)) - { - throw new CMISConstraintException("An object of type '" + objectType.getTypeId() - + "' can't be a child of a folder of type '" + folderType.getTypeId() + "'"); - } - QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName - .createValidLocalName((String) nodeService.getProperty(objectNodeRef, ContentModel.PROP_NAME))); - nodeService.addChild(parentFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, name); - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#removeObjectFromFolder(java.lang.String, java.lang.String) - */ - public void removeObjectFromFolder(String objectId, String folderId) throws CMISNotSupportedException, - CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException, - CMISInvalidArgumentException, CMISPermissionDeniedException - { - try - { - if (folderId == null || folderId.length() == 0) - { - throw new CMISNotSupportedException( - "Unfiling from primary parent folder is not supported. Use deleteObject() instead"); - } - NodeRef objectNodeRef = getObject(objectId, NodeRef.class, true, false, false); - NodeRef parentFolderNodeRef = getFolder(folderId); - if (nodeService.getPrimaryParent(objectNodeRef).getParentRef().equals(parentFolderNodeRef)) - { - throw new CMISNotSupportedException( - "Unfiling from primary parent folder is not supported. Use deleteObject() instead"); - } - nodeService.removeChild(parentFolderNodeRef, objectNodeRef); - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#moveObject(java.lang.String, java.lang.String, java.lang.String) - */ - public void moveObject(String objectId, String targetFolderId, String sourceFolderId) - throws CMISConstraintException, CMISVersioningException, CMISObjectNotFoundException, - CMISInvalidArgumentException, CMISPermissionDeniedException - { - try - { - NodeRef objectNodeRef = getObject(objectId, NodeRef.class, true, false, false); - - NodeRef sourceFolderNodeRef; - // We have a specific requirement in the spec to throw invalidArgument for missing source folders, rather - // than objectNotFound - try - { - sourceFolderNodeRef = getFolder(sourceFolderId); - } - catch (CMISObjectNotFoundException e) - { - throw new CMISInvalidArgumentException(e.getMessage(), e); - } - NodeRef targetFolderNodeRef = getFolder(targetFolderId); - CMISFolderTypeDefinition targetTypeDef = (CMISFolderTypeDefinition) getTypeDefinition(targetFolderNodeRef); - - CMISTypeDefinition objectTypeDef = getTypeDefinition(objectNodeRef); - if (!targetTypeDef.getAllowedTargetTypes().isEmpty() - && !targetTypeDef.getAllowedTargetTypes().contains(objectTypeDef)) - { - throw new CMISConstraintException("Object with '" + objectTypeDef.getTypeId() - + "' Type can't be moved to Folder with '" + targetTypeDef.getTypeId() + "' Type"); - } - - // If this is a primary child node, move it - ChildAssociationRef primaryParentRef = nodeService.getPrimaryParent(objectNodeRef); - if (primaryParentRef.getParentRef().equals(sourceFolderNodeRef)) - { - nodeService.moveNode(objectNodeRef, targetFolderNodeRef, primaryParentRef.getTypeQName(), - primaryParentRef.getQName()); - } - else - { - // Otherwise, reparent it - for (ChildAssociationRef parent : nodeService.getParentAssocs(objectNodeRef, - ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL)) - { - if (parent.getParentRef().equals(sourceFolderNodeRef)) - { - nodeService.removeChildAssociation(parent); - nodeService.addChild(targetFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, parent - .getQName()); - return; - } - } - throw new CMISInvalidArgumentException( - "The Document is not a Child of the Source Folder that was specified"); - } - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#setContentStream(java.lang.String, org.alfresco.service.namespace.QName, - * boolean, java.io.InputStream, java.lang.String) - */ - public boolean setContentStream(String objectId, QName propertyQName, boolean overwriteFlag, - InputStream contentStream, String mimeType) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISContentAlreadyExistsException, CMISStreamNotSupportedException, - CMISInvalidArgumentException, CMISPermissionDeniedException - { - try - { - NodeRef nodeRef = getObject(objectId, NodeRef.class, true, false, false); - - CMISTypeDefinition typeDef = getTypeDefinition(nodeRef); - if (CMISContentStreamAllowedEnum.NOT_ALLOWED.equals(typeDef.getContentStreamAllowed())) - { - throw new CMISStreamNotSupportedException(typeDef); - } - // Alfresco extension for setting the content property - if (propertyQName == null) - { - propertyQName = ContentModel.PROP_CONTENT; - } - - // Determine whether content already exists - boolean existed = contentService.getReader(nodeRef, propertyQName) != null; - if (existed && !overwriteFlag) - { - throw new CMISContentAlreadyExistsException(); - } - - final ContentWriter writer = contentService.getWriter(nodeRef, propertyQName, true); - writer.guessEncoding(); - writer.guessMimetype(null); - writer.setMimetype(mimeType); - writer.putContent(contentStream); - - return existed; - } - catch (AccessDeniedException e) - { - throw new CMISPermissionDeniedException(e.getMessage(), e); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#createPolicy(java.util.Map, java.lang.String, java.util.List) - */ - public String createPolicy(Map properties, String folderId, List policies) - throws CMISConstraintException, CMISRuntimeException, CMISInvalidArgumentException - { - String typeId = (String) properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID); - if (typeId == null) - { - throw new CMISConstraintException("Policy type ID not specified"); - } - CMISTypeDefinition typeDefinition = getTypeDefinition(typeId); - if (typeDefinition.getBaseType().getTypeId() != CMISDictionaryModel.POLICY_TYPE_ID) - { - throw new CMISConstraintException(typeId + " is not a policy type"); - } - if (!typeDefinition.isCreatable()) - { - throw new CMISConstraintException(typeId + " is not a creatable type"); - } - // Should never get here, as currently no policy types are creatable - throw new CMISRuntimeException("Internal error"); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#applyPolicy(java.lang.String, java.lang.String) - */ - public void applyPolicy(String policyId, String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - CMISTypeDefinition typeDef = getTypeDefinition(getReadableObject(objectId, Object.class)); - if (!typeDef.isControllablePolicy()) - { - throw new CMISConstraintException("Type " + typeDef.getTypeId().getId() + " does not allow policies to be applied"); - } - getReadableObject(policyId, CMISTypeDefinition.class); - // Expect exception to be throw by now - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#getAppliedPolicies(java.lang.String, java.lang.String) - */ - public List getAppliedPolicies(String objectId, String filter) throws CMISConstraintException, - CMISVersioningException, CMISObjectNotFoundException, CMISInvalidArgumentException, - CMISPermissionDeniedException, CMISFilterNotValidException - { - // Get the object - getReadableObject(objectId, Object.class); - - // Parse the filter - new PropertyFilter(filter); - - // Nothing else to do - return Collections.emptyList(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISServices#removePolicy(java.lang.String, java.lang.String) - */ - public void removePolicy(String policyId, String objectId) throws CMISConstraintException, CMISVersioningException, - CMISObjectNotFoundException, CMISInvalidArgumentException, CMISPermissionDeniedException - { - CMISTypeDefinition typeDef = getTypeDefinition(getReadableObject(objectId, Object.class)); - if (!typeDef.isControllablePolicy()) - { - throw new CMISConstraintException("Type " + typeDef.getTypeId().getId() + " does not allow policies to be applied"); - } - getReadableObject(policyId, CMISTypeDefinition.class); - // Expect exception to be throw by now - } - - /** - * Validates that a node is versionable. - * - * @param source - * the node - * @throws CMISConstraintException - * if the node is not versionable - * @throws CMISInvalidArgumentException - * if an argument is invalid - */ - private void validateVersionable(NodeRef source) throws CMISConstraintException, CMISInvalidArgumentException - { - CMISTypeDefinition typeDef = getTypeDefinition(source); - if (!typeDef.isVersionable()) - { - throw new CMISConstraintException("Type " + typeDef.getTypeId() + " is not versionable"); - } - } - - /** - * Creates a property map for the version service. - * - * @param versionDescription - * a version description - * @param isMajor - * is this a major version? - * @return the property map - */ - private Map createVersionProperties(String versionDescription, boolean isMajor) - { - Map versionProperties = new HashMap(5); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, isMajor ? VersionType.MAJOR : VersionType.MINOR); - if (versionDescription != null) - { - versionProperties.put(VersionModel.PROP_DESCRIPTION, versionDescription); - } - return versionProperties; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/CanCheckInActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/CanCheckInActionEvaluator.java deleted file mode 100644 index 5592e0d872..0000000000 --- a/source/java/org/alfresco/cmis/mapping/CanCheckInActionEvaluator.java +++ /dev/null @@ -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 . - */ -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 -{ - private NodeService nodeService; - - private PermissionActionEvaluator permissionEvaluator; - - protected CanCheckInActionEvaluator(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISAllowedActionEnum.CAN_CHECKIN); - - permissionEvaluator = new PermissionActionEvaluator(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; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/CheckinCommentProperty.java b/source/java/org/alfresco/cmis/mapping/CheckinCommentProperty.java deleted file mode 100644 index 2ba1089fcc..0000000000 --- a/source/java/org/alfresco/cmis/mapping/CheckinCommentProperty.java +++ /dev/null @@ -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 . - */ -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(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/CompositeActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/CompositeActionEvaluator.java deleted file mode 100644 index 3caadd6cdc..0000000000 --- a/source/java/org/alfresco/cmis/mapping/CompositeActionEvaluator.java +++ /dev/null @@ -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 . - */ -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.
- *
- * Evaluator allows specifying logical operation to calculate the final result, using the specified conditions: conjunction (AND operation; DEFAULT value) or disjunction (OR - * operation).
- *
- * N.B.: each {@link CompositeActionEvaluator} may include other {@link CompositeActionEvaluator} conditions! - * - * @author Dmitry Velichkevich - */ -public class CompositeActionEvaluator extends AbstractActionEvaluator -{ - private List> conditions = new LinkedList>(); - - 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 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 addPermissionCondition(String... permissions) - { - if (null != permissions) - { - conditions.add(new PermissionActionEvaluator(getServiceRegistry(), getAction(), defaultAllowing, permissions)); - } - - return this; - } - - /** - * Add {@link PropertyActionEvaluator} condition to the list. This method implies, that each property from the propertyIdsAndExpectedValues 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 null - * @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions - */ - public CompositeActionEvaluator addPropertyCondition(PropertyDescriptor... propertyIdsAndExpectedValues) - { - if (null != propertyIdsAndExpectedValues) - { - conditions.add(new PropertyActionEvaluator(getServiceRegistry(), getAction(), true, defaultAllowing, propertyIdsAndExpectedValues)); - } - - return this; - } - - /** - * Adds {@link TypeAttributeActionEvaluator} condition to the list. This method implies, that attribute 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 - * attribute parameter - * @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions - */ - public CompositeActionEvaluator addTypeAttributeCondition(TypeDefinitionAttributeEnum attribute, Comparable comparator) - { - if ((null != attribute) && (null != comparator)) - { - conditions.add(new TypeAttributeActionEvaluator(attribute, new Pair>(null, comparator), true, defaultAllowing, - getServiceRegistry(), getAction())); - } - - return this; - } - - /** - * Adds {@link ObjectLockedActionEvaluator} condition to the list. This method implies, that object should not have lockType 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 addLockCondition(LockType lockType) - { - conditions.add(new ObjectLockedActionEvaluator(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: true - object should be PWC, false - object should not be PWC - * @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions - */ - public CompositeActionEvaluator addPwcCondition(boolean pwcExpected) - { - conditions.add(new AspectActionEvaluator(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 expected condition - * - * @param expected - {@link Boolean} value, which determines: true - aspects appliance is expected, false - 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 addAspectCondition(boolean expected, QName... aspects) - { - conditions.add(new AspectActionEvaluator(getServiceRegistry(), getAction(), expected, true, defaultAllowing, aspects)); - return this; - } - - /** - * Adds {@link ParentTypeActionEvaluator} condition to the list. This method implies, that parent of the parentType 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 addParentTypeCondition(ParentTypeEnum parentType) - { - conditions.add(new ParentTypeActionEvaluator(getServiceRegistry(), getAction(), parentType, true)); - return this; - } - - /** - * Adds any condition to the list, if it is not a null - * - * @param condition - {@link AbstractActionEvaluator} instance, which determines some condition - * @return {@link CompositeActionEvaluator} - self-instance, which allows making chain of conditions - */ - public CompositeActionEvaluator addCondition(AbstractActionEvaluator condition) - { - if (null != condition) - { - conditions.add(condition); - } - - return this; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/ContentStreamIdProperty.java b/source/java/org/alfresco/cmis/mapping/ContentStreamIdProperty.java deleted file mode 100644 index c095228cb3..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ContentStreamIdProperty.java +++ /dev/null @@ -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 . - */ -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; - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/ContentStreamLengthProperty.java b/source/java/org/alfresco/cmis/mapping/ContentStreamLengthProperty.java deleted file mode 100644 index c7b2cc0a76..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ContentStreamLengthProperty.java +++ /dev/null @@ -1,93 +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 . - */ -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.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.namespace.QName; - -/** - * Accessor for CMIS content stream length property - * - * @author andyh - */ -public class ContentStreamLengthProperty extends AbstractSimpleProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public ContentStreamLengthProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT); - if (value != null) - { - ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value); - return contentData.getSize(); - } - else - { - return 0L; - } - } - - public String getLuceneFieldName() - { - StringBuilder field = new StringBuilder(128); - field.append("@"); - field.append(ContentModel.PROP_CONTENT); - field.append(".size"); - return field.toString(); - } - - protected String getValueAsString(Serializable value) - { - Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.LONG), value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - return asString; - } - - protected QName getQNameForExists() - { - return ContentModel.PROP_CONTENT; - } - - - protected DataTypeDefinition getInDataType() - { - return getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.LONG); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/ContentStreamMimetypeProperty.java b/source/java/org/alfresco/cmis/mapping/ContentStreamMimetypeProperty.java deleted file mode 100644 index ed760e2937..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ContentStreamMimetypeProperty.java +++ /dev/null @@ -1,92 +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 . - */ -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.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.namespace.QName; - -/** - * Accessor for CMIS content stream mimetype property - * - * @author andyh - */ -public class ContentStreamMimetypeProperty extends AbstractSimpleProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public ContentStreamMimetypeProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT); - if (value != null) - { - ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value); - return contentData.getMimetype(); - } - else - { - return ""; - } - } - - public String getLuceneFieldName() - { - StringBuilder field = new StringBuilder(128); - field.append("@"); - field.append(ContentModel.PROP_CONTENT); - field.append(".mimetype"); - return field.toString(); - } - - protected String getValueAsString(Serializable value) - { - Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.TEXT), value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - return asString; - } - - protected QName getQNameForExists() - { - return ContentModel.PROP_CONTENT; - } - - protected DataTypeDefinition getInDataType() - { - return getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.TEXT); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/DirectProperty.java b/source/java/org/alfresco/cmis/mapping/DirectProperty.java deleted file mode 100644 index 28626c5f30..0000000000 --- a/source/java/org/alfresco/cmis/mapping/DirectProperty.java +++ /dev/null @@ -1,178 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.repo.search.adaptor.lucene.LuceneQueryParserAdaptor; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -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; -import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException; - -/** - * A simple 1-1 property mapping from a CMIS property name to an alfresco property - * - * @author andyh - */ -public class DirectProperty extends AbstractSimpleProperty -{ - /* (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractSimpleProperty#getRangeMax() - */ - @Override - protected String getRangeMax() - { - if(getInDataType().getName().equals(DataTypeDefinition.DATE)) - { - return "MAX"; - } - else if(getInDataType().getName().equals(DataTypeDefinition.DATETIME)) - { - return "MAX"; - } - else - { - return super.getRangeMax(); - } - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractSimpleProperty#getRangeMin() - */ - @Override - protected String getRangeMin() - { - if(getInDataType().getName().equals(DataTypeDefinition.DATE)) - { - return "MIN"; - } - else if(getInDataType().getName().equals(DataTypeDefinition.DATETIME)) - { - return "MIN"; - } - else - { - return super.getRangeMin(); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractSimpleProperty#getLuceneSortField() - */ - @Override - public String getLuceneSortField(LuceneQueryParserAdaptor lqpa) throws E - { - - String field = getLuceneFieldName(); - // need to find the real field to use - - PropertyDefinition propertyDef = getServiceRegistry().getDictionaryService().getProperty(QName.createQName(field.substring(1))); - - if (propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT)) - { - throw new CmisInvalidArgumentException("Order on content properties is not curently supported"); - } - else if ((propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT)) || (propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT))) - { - field = lqpa.getSortField(field); - } - else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME)) - { - field = lqpa.getDatetimeSortField(field, propertyDef); - } - - return field; - } - - private QName alfrescoName; - - /** - * Construct - * - * @param serviceRegistry - * @param propertyName - * @param alfrescoName - */ - public DirectProperty(ServiceRegistry serviceRegistry, String propertyName, QName alfrescoName) - { - super(serviceRegistry, propertyName); - this.alfrescoName = alfrescoName; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.AbstractPropertyAccessor#getMappedProperty() - */ - public QName getMappedProperty() - { - return alfrescoName; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - return getServiceRegistry().getNodeService().getProperty(nodeRef, alfrescoName); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef) - */ - public Serializable getValue(AssociationRef assocRef) - { - return null; - } - - public String getLuceneFieldName() - { - StringBuilder field = new StringBuilder(64); - field.append("@"); - field.append(alfrescoName); - return field.toString(); - } - - protected String getValueAsString(Serializable value) - { - PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(alfrescoName); - Object converted = DefaultTypeConverter.INSTANCE.convert(pd.getDataType(), value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - return asString; - } - - protected QName getQNameForExists() - { - return alfrescoName; - } - - protected DataTypeDefinition getInDataType() - { - PropertyDefinition pd = getServiceRegistry().getDictionaryService().getProperty(alfrescoName); - return pd.getDataType(); - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/FixedValueActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/FixedValueActionEvaluator.java deleted file mode 100644 index e3acfe4ba1..0000000000 --- a/source/java/org/alfresco/cmis/mapping/FixedValueActionEvaluator.java +++ /dev/null @@ -1,63 +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 . - */ -package org.alfresco.cmis.mapping; - -import org.alfresco.cmis.CMISAllowedActionEnum; -import org.alfresco.service.ServiceRegistry; - -/** - * Action Evaluator whose evaluation is fixed - * - * @author davidc - * - */ -public class FixedValueActionEvaluator extends AbstractActionEvaluator -{ - private boolean allowed; - - /** - * Construct - * - * @param serviceRegistry - * @param action - */ - protected FixedValueActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, boolean allowed) - { - super(serviceRegistry, action); - this.allowed = allowed; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isAllowed(T object) - { - return allowed; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("FixedValueActionEvaluator[action=").append(getAction()); - builder.append(", allowed=").append(allowed).append("]"); - return builder.toString(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/FixedValueProperty.java b/source/java/org/alfresco/cmis/mapping/FixedValueProperty.java deleted file mode 100644 index d820e85534..0000000000 --- a/source/java/org/alfresco/cmis/mapping/FixedValueProperty.java +++ /dev/null @@ -1,276 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -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.util.EqualsHelper; -import org.alfresco.util.SearchLanguageConversion; - -/** - * Property accessor for fixed value mapping (eg to null, true, etc) - * - * @author andyh - */ -public class FixedValueProperty extends AbstractProperty -{ - private Serializable fixedValue; - - /** - * Construct - * - * @param serviceRegistry - * @param propertyName - * @param fixedValue - */ - public FixedValueProperty(ServiceRegistry serviceRegistry, String propertyName, Serializable fixedValue) - { - super(serviceRegistry, propertyName); - this.fixedValue = fixedValue; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - return fixedValue; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef) - */ - public Serializable getValue(AssociationRef assocRef) - { - return fixedValue; - } - - /* - * (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 buildLuceneEquality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - if (EqualsHelper.nullSafeEquals(value, fixedValue)) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) - */ - public Q buildLuceneExists(LuceneQueryParserAdaptor lqpa, Boolean not) throws E - { - if (not) - { - if (fixedValue == null) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - else - { - if (fixedValue == null) - { - return lqpa.getMatchNoneQuery(); - } - else - { - return lqpa.getMatchAllQuery(); - } - } - - } - - /* - * (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) - */ - @SuppressWarnings("unchecked") - public Q buildLuceneGreaterThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - if (value instanceof Comparable) - { - @SuppressWarnings("rawtypes") - Comparable comparable = (Comparable) value; - if (comparable.compareTo(fixedValue) > 0) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - - /* - * (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) - */ - @SuppressWarnings("unchecked") - public Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - if (value instanceof Comparable) - { - @SuppressWarnings("rawtypes") - Comparable comparable = (Comparable) value; - if (comparable.compareTo(fixedValue) >= 0) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - - /* - * (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) - */ - @SuppressWarnings("unchecked") - public Q buildLuceneLessThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - if (value instanceof Comparable) - { - @SuppressWarnings("rawtypes") - Comparable comparable = (Comparable) value; - if (comparable.compareTo(fixedValue) < 0) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - - /* - * (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) - */ - @SuppressWarnings("unchecked") - public Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - if (value instanceof Comparable) - { - @SuppressWarnings("rawtypes") - Comparable comparable = (Comparable) value; - if (comparable.compareTo(fixedValue) <= 0) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) - */ - public Q buildLuceneLike(LuceneQueryParserAdaptor lqpa, Serializable value, Boolean not) throws E - { - if (value != null) - { - boolean matches = false; - - Object converted = DefaultTypeConverter.INSTANCE.convert(value.getClass(), value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - String regExpression = SearchLanguageConversion.convertSQLLikeToRegex(asString); - Pattern pattern = Pattern.compile(regExpression); - String target = DefaultTypeConverter.INSTANCE.convert(String.class, fixedValue); - Matcher matcher = pattern.matcher(target); - if (matcher.matches()) - { - matches = true; - } - - if (matches == !not) - { - return lqpa.getMatchAllQuery(); - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - else - { - return lqpa.getMatchNoneQuery(); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() - */ - public String getLuceneSortField(LuceneQueryParserAdaptor lqpa) - { - throw new UnsupportedOperationException(); - } - - public String getLuceneFieldName() - { - throw new UnsupportedOperationException(); - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/IsImmutableProperty.java b/source/java/org/alfresco/cmis/mapping/IsImmutableProperty.java deleted file mode 100644 index 5f93e91815..0000000000 --- a/source/java/org/alfresco/cmis/mapping/IsImmutableProperty.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Property accessor for CMIS is immutable property - * - * @author dward - */ -public class IsImmutableProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public IsImmutableProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_IS_IMMUTABLE); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - if (isWorkingCopy(nodeRef)) - { - return false; - } - if (getVersionSeries(nodeRef).equals(nodeRef)) - { - return isImmutable(nodeRef); - } - return true; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/IsLatestMajorVersionProperty.java b/source/java/org/alfresco/cmis/mapping/IsLatestMajorVersionProperty.java deleted file mode 100644 index ea30b4d553..0000000000 --- a/source/java/org/alfresco/cmis/mapping/IsLatestMajorVersionProperty.java +++ /dev/null @@ -1,103 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.version.VersionBaseModel; -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; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.cmr.version.VersionType; - -/** - * Accessor for CMIS is latest major version property - * - * @author dward - */ -public class IsLatestMajorVersionProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public IsLatestMajorVersionProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - if (isWorkingCopy(nodeRef)) - { - return false; - } - NodeRef versionSeries = getVersionSeries(nodeRef); - ServiceRegistry serviceRegistry = getServiceRegistry(); - VersionService versionService = serviceRegistry.getVersionService(); - VersionHistory versionHistory = versionService.getVersionHistory(versionSeries); - if (versionHistory == null) - { - return false; - } - - NodeRef versionNodeRef = nodeRef; - if (!nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL)) - { - String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL); - if (versionLabel == null) - { - return false; - } - Version version = versionHistory.getVersion(versionLabel); - if (version == null) - { - return false; - } - versionNodeRef = version.getFrozenStateNodeRef(); - } - - // Go back in time to the last major version - Version currentVersion = versionService.getCurrentVersion(versionSeries); - while (currentVersion != null) - { - if (currentVersion.getVersionType() == VersionType.MAJOR) - { - return currentVersion.getFrozenStateNodeRef().equals(versionNodeRef); - } - // We got to the current node and its not major. We failed! - else if (currentVersion.getFrozenStateNodeRef().equals(versionNodeRef)) - { - return false; - } - currentVersion = versionHistory.getPredecessor(currentVersion); - } - return false; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/IsLatestVersionProperty.java b/source/java/org/alfresco/cmis/mapping/IsLatestVersionProperty.java deleted file mode 100644 index 230bb15b08..0000000000 --- a/source/java/org/alfresco/cmis/mapping/IsLatestVersionProperty.java +++ /dev/null @@ -1,81 +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 . - */ -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; - -/** - * Accesser for CMIS is latest version property - * - * @author dward - */ -public class IsLatestVersionProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public IsLatestVersionProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_IS_LATEST_VERSION); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - if (isWorkingCopy(nodeRef) || getVersionSeries(nodeRef).equals(nodeRef) && !hasWorkingCopy(nodeRef)) - { - return true; - } - NodeRef versionSeries = getVersionSeries(nodeRef); - if (hasWorkingCopy(versionSeries)) - { - return false; - } - - ServiceRegistry serviceRegistry = getServiceRegistry(); - String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL); - if (versionLabel == null) - { - return false; - } - VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries); - if (versionHistory == null) - { - return false; - } - Version version = versionHistory.getVersion(versionLabel); - if (version == null) - { - return false; - } - return versionHistory.getHeadVersion().getFrozenStateNodeRef().equals(version.getFrozenStateNodeRef()); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/IsMajorVersionProperty.java b/source/java/org/alfresco/cmis/mapping/IsMajorVersionProperty.java deleted file mode 100644 index e0603a1711..0000000000 --- a/source/java/org/alfresco/cmis/mapping/IsMajorVersionProperty.java +++ /dev/null @@ -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 . - */ -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.VersionHistory; -import org.alfresco.service.cmr.version.VersionType; - -/** - * Accessor for CMIS is major version property - * - * @author dward - */ -public class IsMajorVersionProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public IsMajorVersionProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_IS_MAJOR_VERSION); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - if (isWorkingCopy(nodeRef)) - { - return false; - } - ServiceRegistry serviceRegistry = getServiceRegistry(); - String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL); - if (versionLabel == null) - { - return false; - } - NodeRef versionSeries = getVersionSeries(nodeRef); - VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries); - if (versionHistory == null) - { - return false; - } - return versionHistory.getVersion(versionLabel).getVersionType() == VersionType.MAJOR; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/IsVersionSeriesCheckedOutProperty.java b/source/java/org/alfresco/cmis/mapping/IsVersionSeriesCheckedOutProperty.java deleted file mode 100644 index 9908ef9426..0000000000 --- a/source/java/org/alfresco/cmis/mapping/IsVersionSeriesCheckedOutProperty.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Get the CMIS version series checked out property - * - * @author dward - */ -public class IsVersionSeriesCheckedOutProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public IsVersionSeriesCheckedOutProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - return isWorkingCopy(nodeRef) || hasWorkingCopy(getVersionSeries(nodeRef)); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java b/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java deleted file mode 100644 index e3aacdb824..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ObjectIdProperty.java +++ /dev/null @@ -1,201 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; -import java.util.ArrayList; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISQueryException; -import org.alfresco.cmis.CMISServices; -import org.alfresco.model.ContentModel; -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.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; - -/** - * Get the CMIS object id property. - * - * @author andyh - * @author dward - */ -public class ObjectIdProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public ObjectIdProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_OBJECT_ID); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - NodeRef versionSeries; - if (isWorkingCopy(nodeRef) || (versionSeries = getVersionSeries(nodeRef)).equals(nodeRef)) - { - return nodeRef.toString(); - } - else - { - return new StringBuilder(1024).append(versionSeries.toString()).append(';').append( - getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL)) - .toString(); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef) - */ - public Serializable getValue(AssociationRef assocRef) - { - return CMISServices.ASSOC_ID_PREFIX + assocRef.getId(); - } - - public String getLuceneFieldName() - { - return "ID"; - } - - private StoreRef getStore(LuceneQueryParserAdaptor lqpa) - { - ArrayList stores = lqpa.getSearchParameters().getStores(); - if(stores.size() < 1) - { - // default - return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; - } - return stores.get(0); - } - - private String getValueAsString(LuceneQueryParserAdaptor lqpa, Serializable value) - { - String nodeRefStr = null; - if(!NodeRef.isNodeRef((String)value)) - { - // assume the object id is the node guid - StoreRef storeRef = getStore(lqpa); - nodeRefStr = storeRef.toString() + "/" + (String)value; - } - else - { - nodeRefStr = (String)value; - } - - Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), nodeRefStr); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - return asString; - } - - /* - * (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 buildLuceneEquality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - String field = getLuceneFieldName(); - String stringValue = getValueAsString(lqpa, value); - return lqpa.getIdentifierQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) - */ - public Q buildLuceneExists(LuceneQueryParserAdaptor lqpa, Boolean not) throws E - { - if (not) - { - return lqpa.getMatchNoneQuery(); - } else - { - return lqpa.getMatchAllQuery(); - } - } - - /* - * (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 buildLuceneGreaterThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() +" can not be used in a 'greater than' comparison"); - } - - /* - * (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 buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than or equals' comparison"); - } - - /* - * (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 buildLuceneLessThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than' comparison"); - } - - /* - * (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 buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than or equals' comparison"); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.property.NamedPropertyAccessor#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * java.lang.String, java.io.Serializable, java.lang.Boolean) - */ - public Q buildLuceneLike(LuceneQueryParserAdaptor lqpa, Serializable value, Boolean not) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'like' comparison"); - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.property.NamedPropertyAccessor#getLuceneSortField(java.lang.String) - */ - public String getLuceneSortField(LuceneQueryParserAdaptor lqpa) - { - return getLuceneFieldName(); - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/ObjectLockedActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/ObjectLockedActionEvaluator.java deleted file mode 100644 index 4544606934..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ObjectLockedActionEvaluator.java +++ /dev/null @@ -1,80 +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 . - */ -package org.alfresco.cmis.mapping; - -import org.alfresco.cmis.CMISAllowedActionEnum; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.lock.LockService; -import org.alfresco.service.cmr.lock.LockType; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.apache.chemistry.abdera.ext.CMISAllowableActions; - -/** - * This evaluator determines an action availability in accordance with {@link LockType} lock parameter and in accordance with rules of checking application of the lock. The rules - * are:
- * - is it expected that object had been locked - *
- * This evaluator is generic, because it is used in the scope of {@link CompositeActionEvaluator} - * - * @author Dmitry Velichkevich - */ -public class ObjectLockedActionEvaluator extends AbstractActionEvaluator -{ - private NodeService nodeService; - - private LockService lockService; - - private LockType lockType; - - private boolean lockExpected; - - /** - * Constructor - * - * @param lockType - {@link LockType} enumeration value, which determines type of the lock, which should be validated - * @param lockExpected - {@link Boolean} value, which determines: true - object should be locked and lock should satisfy to the lockType, - * false - object should not have the lockType lock - * @param serviceRegistry - {@link ServiceRegistry} instance - * @param action - {@link CMISAllowableActions} enumeration value, which determines the action to check - */ - protected ObjectLockedActionEvaluator(LockType lockType, boolean lockExpected, ServiceRegistry serviceRegistry, CMISAllowedActionEnum action) - { - super(serviceRegistry, action); - this.lockType = lockType; - this.lockExpected = lockExpected; - - nodeService = serviceRegistry.getNodeService(); - lockService = serviceRegistry.getLockService(); - } - - @Override - public boolean isAllowed(ObjectType object) - { - NodeRef nodeRef = (object instanceof NodeRef) ? ((NodeRef) object) : (null); - - if ((null != lockType) && nodeService.exists(nodeRef)) - { - boolean locked = lockType == lockService.getLockType(nodeRef); - return (lockExpected && locked) || (!lockExpected && !locked); - } - - return false; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/ObjectTypeIdProperty.java b/source/java/org/alfresco/cmis/mapping/ObjectTypeIdProperty.java deleted file mode 100644 index 4e116d5255..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ObjectTypeIdProperty.java +++ /dev/null @@ -1,179 +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 . - */ -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 ObjectTypeIdProperty extends AbstractProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public ObjectTypeIdProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_OBJECT_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).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).getTypeId().getId(); - } - - public String getLuceneFieldName() - { - return "EXACTTYPE"; - } - - private String getValueAsString(Serializable value) - { - // Object converted = - // DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.QNAME), - // value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, value); - return asString; - } - - /* - * (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 buildLuceneEquality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - String field = getLuceneFieldName(); - String stringValue = getValueAsString(value); - CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue); - return lqpa.getFieldQuery(field, type.getTypeId().getQName().toString(), AnalysisMode.IDENTIFIER, luceneFunction); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) - */ - public Q buildLuceneExists(LuceneQueryParserAdaptor lqpa, Boolean not) throws E - { - if (not) - { - return lqpa.getMatchNoneQuery(); - } - else - { - return lqpa.getMatchAllQuery(); - } - } - - /* - * (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 buildLuceneGreaterThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than' comparison"); - } - - /* - * (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 buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'greater than or equals' comparison"); - } - - /* - * (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 buildLuceneLessThan(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than' comparison"); - } - - /* - * (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 buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - throw new CMISQueryException("Property " + getName() + " can not be used in a 'less than or equals' comparison"); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) - */ - public Q buildLuceneLike(LuceneQueryParserAdaptor lqpa, Serializable value, Boolean not) throws E - { - String field = getLuceneFieldName(); - String stringValue = getValueAsString(value); - CMISTypeDefinition type = getServiceRegistry().getCMISDictionaryService().findType(stringValue); - String typeQName = type.getTypeId().getQName().toString(); - - Q q = lqpa.getLikeQuery(field, typeQName, AnalysisMode.IDENTIFIER); - if (not) - { - q = lqpa.getNegatedQuery(q); - } - return q; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#getLuceneSortField() - */ - public String getLuceneSortField(LuceneQueryParserAdaptor lqpa) - { - return getLuceneFieldName(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/ParentActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/ParentActionEvaluator.java deleted file mode 100644 index 67cdde425b..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ParentActionEvaluator.java +++ /dev/null @@ -1,77 +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 . - */ -package org.alfresco.cmis.mapping; - -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Action Evaluator whose evaluation takes place on parent - * - * @author davidc - */ -public class ParentActionEvaluator extends AbstractActionEvaluator -{ - private AbstractActionEvaluator evaluator; - - /** - * Construct - * - * @param serviceRegistry - * @param action - */ - protected ParentActionEvaluator(AbstractActionEvaluator evaluator) - { - super(evaluator.getServiceRegistry(), evaluator.getAction()); - this.evaluator = evaluator; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isAllowed(NodeRef nodeRef) - { - if (nodeRef.equals(getServiceRegistry().getCMISService().getDefaultRootNodeRef())) - { - return false; - } - - ChildAssociationRef car = getServiceRegistry().getNodeService().getPrimaryParent(nodeRef); - if ((car != null) && (car.getParentRef() != null)) - { - return evaluator.isAllowed(car.getParentRef()); - } - - return false; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("ParentActionEvaluator[evaluator=").append(evaluator).append("]"); - return builder.toString(); - } -} - diff --git a/source/java/org/alfresco/cmis/mapping/ParentProperty.java b/source/java/org/alfresco/cmis/mapping/ParentProperty.java deleted file mode 100644 index 81269642fb..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ParentProperty.java +++ /dev/null @@ -1,137 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -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.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; - -/** - * Get the CMIS parent property - * - * @author andyh - * - */ -public class ParentProperty extends AbstractProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public ParentProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_PARENT_ID); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - if (nodeRef.equals(getServiceRegistry().getCMISService().getDefaultRootNodeRef())) - { - return null; - } - - ChildAssociationRef car = getServiceRegistry().getNodeService().getPrimaryParent(nodeRef); - if ((car != null) && (car.getParentRef() != null)) - { - return car.getParentRef().toString(); - } - else - { - return null; - } - } - - public String getLuceneFieldName() - { - return "PARENT"; - } - - private String getValueAsString(Serializable value) - { - Object converted = DefaultTypeConverter.INSTANCE.convert(getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.NODE_REF), value); - String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted); - return asString; - } - - /* - * (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 buildLuceneEquality(LuceneQueryParserAdaptor lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - String field = getLuceneFieldName(); - String stringValue = getValueAsString(value); - return lqpa.getFieldQuery(field, stringValue, AnalysisMode.IDENTIFIER, luceneFunction); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.lang.Boolean) - */ - public Q buildLuceneExists(LuceneQueryParserAdaptor lqpa, Boolean not) throws E - { - if (not) - { - return lqpa.getFieldQuery("ISROOT", "T", AnalysisMode.IDENTIFIER, LuceneFunction.FIELD); - } else - { - return lqpa.getNegatedQuery(lqpa.getFieldQuery("ISROOT", "T", AnalysisMode.IDENTIFIER, LuceneFunction.FIELD)); - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyLuceneBuilder#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, java.io.Serializable, java.lang.Boolean) - */ - public Q buildLuceneLike(LuceneQueryParserAdaptor 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 String getLuceneSortField(LuceneQueryParserAdaptor lqpa) - { - return getLuceneFieldName(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/ParentTypeActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/ParentTypeActionEvaluator.java deleted file mode 100644 index 8088763c59..0000000000 --- a/source/java/org/alfresco/cmis/mapping/ParentTypeActionEvaluator.java +++ /dev/null @@ -1,131 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.util.List; - -import org.alfresco.cmis.CMISAllowedActionEnum; -import org.alfresco.cmis.CMISServices; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.apache.chemistry.abdera.ext.CMISAllowableActions; -import org.apache.chemistry.opencmis.commons.impl.jaxb.MultiFilingServicePort; - -/** - * This evaluator determines an action availability in accordance with parent(s) of object. The rules are:
- * - is it expected that object has parent of {@link ParentTypeEnum} or not.
- *
- * This evaluator is generic, because it is used in the scope of {@link CompositeActionEvaluator} - * - * @author Dmitry Velichkevich - */ -public class ParentTypeActionEvaluator extends AbstractActionEvaluator -{ - private CMISServices cmisServices; - - private NodeService nodeService; - - private ParentTypeEnum parentType; - - private boolean expected; - - /** - * Constructor - * - * @param serviceRegistry - {@link ServiceRegistry} instance - * @param action - {@link CMISAllowableActions} enumeration value, which determines the action to check - * @param parentType - {@link ParentTypeEnum} enumeration value, which determines type of parent, which should be validated - * @param expected - {@link Boolean} value, which determines: true - object should have parentType parent, false - object should NOT have - * parentType parent - */ - protected ParentTypeActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, ParentTypeEnum parentType, boolean expected) - { - super(serviceRegistry, action); - this.parentType = parentType; - this.expected = expected; - - cmisServices = serviceRegistry.getCMISService(); - nodeService = serviceRegistry.getNodeService(); - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(java.lang.Object) - */ - @Override - public boolean isAllowed(ObjectType object) - { - NodeRef nodeRef = (object instanceof NodeRef) ? ((NodeRef) object) : (null); - - NodeRef rootNodeRef = cmisServices.getDefaultRootNodeRef(); - if ((null == nodeRef) || rootNodeRef.equals(nodeRef)) - { - return false; - } - - List parentAssocs = nodeService.getParentAssocs(nodeRef); - if ((ParentTypeEnum.REPOSITORY_ROOT == parentType) || (ParentTypeEnum.PRIMARY_REPOSITORY_ROOT == parentType)) - { - ChildAssociationRef root = null; - for (ChildAssociationRef ref : parentAssocs) - { - root = (rootNodeRef.equals(ref.getParentRef())) ? (ref) : (null); - if (null != root) - { - if ((ParentTypeEnum.PRIMARY_REPOSITORY_ROOT == parentType) && !ref.isPrimary()) - { - root = null; - } - - break; - } - } - - return (expected) ? (null != root) : (null == root); - } - - return (expected) ? (parentAssocs.size() > 1) : (1 == parentAssocs.size()); - } - - /** - * Enumeration of type of parents, which may be required to check availability of some action for an object - * - * @author Dmitry Velichkevich - * @see MultiFilingServicePort - */ - public static enum ParentTypeEnum - { - /** - * One or more parents, which are not primary (see {@link MultiFilingServicePort#addObjectToFolder(String, String, String, Boolean, javax.xml.ws.Holder)} and - * {@link MultiFilingServicePort#removeObjectFromFolder(String, String, String, javax.xml.ws.Holder)}) - */ - MULTI_FILED, - - /** - * Default repository root as a primary or one of the multi filed parents - */ - REPOSITORY_ROOT, - - /** - * Default repository root only as primary parent - */ - PRIMARY_REPOSITORY_ROOT; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/PathProperty.java b/source/java/org/alfresco/cmis/mapping/PathProperty.java deleted file mode 100644 index 0b57298144..0000000000 --- a/source/java/org/alfresco/cmis/mapping/PathProperty.java +++ /dev/null @@ -1,128 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISServices; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.repository.Path.ChildAssocElement; - -/** - * Get the CMIS path property. - * - * @author davidc - */ -public class PathProperty extends AbstractProperty -{ - private CMISServices cmisService; - - /** - * Construct - * - * @param serviceRegistry - */ - public PathProperty(ServiceRegistry serviceRegistry, CMISServices cmisService) - { - super(serviceRegistry, CMISDictionaryModel.PROP_PATH); - this.cmisService = cmisService; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - Path path = getServiceRegistry().getNodeService().getPath(nodeRef); - return toDisplayPath(path); - } - - - private String toDisplayPath(final Path path) - { - final StringBuilder displayPath = new StringBuilder(64); - - // skip to CMIS root path - NodeRef rootNode = cmisService.getDefaultRootNodeRef(); - int i = 0; - while (i < path.size()) - { - Path.Element element = path.get(i); - if (element instanceof ChildAssocElement) - { - ChildAssociationRef assocRef = ((ChildAssocElement)element).getRef(); - NodeRef node = assocRef.getChildRef(); - if (node.equals(rootNode)) - { - break; - } - } - i++; - } - - if (i == path.size()) - { - // TODO: - //throw new AlfrescoRuntimeException("Path " + path + " not in CMIS root node scope"); - } - - if (path.size() - i == 1) - { - // render root path - displayPath.append("/"); - } - else - { - // render CMIS scoped path - i++; - final int pathStart = i; - AuthenticationUtil.runAs(new RunAsWork() - { - - @Override - public Void doWork() throws Exception - { - for (int j = pathStart; j < path.size(); j++) - { - Path.Element element = path.get(j); - if (element instanceof ChildAssocElement) - { - ChildAssociationRef assocRef = ((ChildAssocElement)element).getRef(); - NodeRef node = assocRef.getChildRef(); - displayPath.append("/"); - displayPath.append(getServiceRegistry().getNodeService().getProperty(node, ContentModel.PROP_NAME)); - } - } - return null; - } - }, AuthenticationUtil.getSystemUserName()); - } - - return displayPath.toString(); - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/PermissionActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/PermissionActionEvaluator.java deleted file mode 100644 index f0a7f83bac..0000000000 --- a/source/java/org/alfresco/cmis/mapping/PermissionActionEvaluator.java +++ /dev/null @@ -1,91 +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 . - */ -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.security.AccessStatus; -import org.alfresco.service.cmr.security.PermissionService; - -/** - * Alfresco Permission based Action Evaluator - * - * @author davidc - */ -public class PermissionActionEvaluator extends AbstractActionEvaluator -{ - private String[] permissions; - - private boolean defaultAllowing; - - private PermissionService permissionService; - - /** - * Construct - * - * @param serviceRegistry - * @param permission - */ - protected PermissionActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, boolean defaultAllowing, String... permission) - { - super(serviceRegistry, action); - this.permissions = permission; - this.defaultAllowing = defaultAllowing; - this.permissionService = serviceRegistry.getPermissionService(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isAllowed(ObjectType object) - { - if (!(object instanceof NodeRef)) - { - return defaultAllowing; - } - - NodeRef nodeRef = (NodeRef) object; - for (String permission : permissions) - { - if (permissionService.hasPermission(nodeRef, permission) == AccessStatus.DENIED) - { - return false; - } - } - - return true; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("PermissionActionEvaluator[action=").append(getAction()); - builder.append(", permissions="); - for (String permission : permissions) - { - builder.append(permission).append(","); - } - builder.append("]"); - return builder.toString(); - } - -} diff --git a/source/java/org/alfresco/cmis/mapping/PropertyActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/PropertyActionEvaluator.java deleted file mode 100644 index 43744131d5..0000000000 --- a/source/java/org/alfresco/cmis/mapping/PropertyActionEvaluator.java +++ /dev/null @@ -1,200 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISAllowedActionEnum; -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISInvalidArgumentException; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.AssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.apache.chemistry.abdera.ext.CMISAllowableActions; - -/** - * This evaluator determines an action availability in accordance with collection of {@link PropertyDescriptor} and in accordance with rules of checking of the object properties. - * The rules are:
- * - should each specific property in the list satisfy all the conditions, which are specified in appropriate {@link PropertyDescriptor} instance or at least 1 property - * satisfaction is enough.
- *
- * This evaluator is generic, because it is used in the scope of {@link CompositeActionEvaluator} - * - * @author Dmitry Velichkevich - * @see PropertyDescriptor - */ -public class PropertyActionEvaluator extends AbstractActionEvaluator -{ - private PropertyDescriptor[] propertyIdsAndExpectedValues; - - private boolean allPropertiesConcur; - - private boolean defaultAllowing; - - /** - * Constructor - * - * @param serviceRegistry - {@link ServiceRegistry} instance - * @param action - {@link CMISAllowableActions} enumeration value, which determines the action to check - * @param allPropertiesConcur - {@link Boolean} value, which determines: true - each specific object property should satisfy all the conditions of appropriate - * {@link PropertyDescriptor}, false - at least 1 object property satisfaction is enough - * @param defaultAllowing - {@link Boolean} value, which determines availability of action for several special cases (invalid object id, empty collection of the aspects etc.) - * @param propertyIdsAndExpectedValues - {@link PropertyDescriptor}... collection, which specifies all the properties, which should be validated on an object - */ - public PropertyActionEvaluator(ServiceRegistry serviceRegistry, CMISAllowedActionEnum action, boolean allPropertiesConcur, boolean defaultAllowing, - PropertyDescriptor... propertyIdsAndExpectedValues) - { - super(serviceRegistry, action); - this.propertyIdsAndExpectedValues = propertyIdsAndExpectedValues; - this.allPropertiesConcur = allPropertiesConcur; - } - - @Override - public boolean isAllowed(ValidatingObjectType object) - { - boolean result = defaultAllowing; - - if (null != propertyIdsAndExpectedValues) - { - for (PropertyDescriptor descriptor : propertyIdsAndExpectedValues) - { - if ((null != descriptor) && (null != descriptor.getPropertyId())) - { - Serializable left = null; - - try - { - if (object instanceof NodeRef) - { - left = getServiceRegistry().getCMISService().getProperty((NodeRef) object, descriptor.getPropertyId()); - } - else - { - if (object instanceof AssociationRef) - { - left = getServiceRegistry().getCMISService().getProperty((AssociationRef) object, descriptor.getPropertyId()); - } - else - { - return false; - } - } - } - catch (CMISInvalidArgumentException e) - { - throw new RuntimeException(e.toString(), e); - } - - result = descriptor.satisfies(left); - - if ((allPropertiesConcur && !result) || (!allPropertiesConcur && result)) - { - break; - } - } - } - } - - return result; - } - - /** - * This class encapsulates description of object property to validate some actual object property against defined condition. This, in turn, allows determine, if some action is - * allowable for an object in accordance with value or values of the property or properties.
- *
- * N.B.:null expected value is supported!
- * The class introduces the following fields:
- * - property definition id (subject to reference is {@link CMISDictionaryModel}; {@link PropertyDescriptor#getPropertyId()}); - expected property value - * {@link PropertyDescriptor#getPropertyValue()}; - may property be equal to null {@link PropertyDescriptor#isNullExpected()} - * - * @author Dmitry Velichkevich - * @see CMISDictionaryModel - */ - public static class PropertyDescriptor - { - private String propertyId; - - private Serializable propertyValue; - - private boolean nullExpected; - - /** - * Constructor - * - * @param propertyId - {@link String} value, which determines property definition id (subject to reference is {@link CMISDictionaryModel}) - * @param propertyValue - {@link Serializable} instance, which specifies expected property value - * @param nullExpected - {@link Boolean} value, which determines: true - property may be null, false - property can't be equal to - * null (this leads to ignoring {@link PropertyDescriptor#getPropertyValue()} value) - */ - public PropertyDescriptor(String propertyId, Serializable propertyValue, boolean nullExpected) - { - this.propertyId = propertyId; - this.propertyValue = propertyValue; - this.nullExpected = nullExpected; - } - - /** - * Getter - * - * @return {@link String} value, which represents one of the {@link CMISDictionaryModel} property definition ids - */ - public String getPropertyId() - { - return propertyId; - } - - /** - * Getter - * - * @return {@link Serializable} instance, which specifies expected property value - */ - public Serializable getPropertyValue() - { - return propertyValue; - } - - /** - * Getter - * - * @return {@link Boolean} value, which determines: true - property may be null, false - property can't be equal to null - * (this leads to ignoring {@link PropertyDescriptor#getPropertyValue()} value) - */ - public boolean isNullExpected() - { - return nullExpected; - } - - /** - * This method checks whether specified value satisfies to all the defined conditions in current instance of {@link PropertyDescriptor} - * - * @param value - {@link Serializable} instance, which represents actual value of some object property - * @return {@link Boolean} value, which determines: true - specified value satisfies to all the defined conditions, false - specified - * value doesn't satisfy to all the defined conditions - */ - public boolean satisfies(Serializable value) - { - if (!nullExpected) - { - return null != value; - } - - return (null != value) ? (value.equals(propertyValue)) : (null == propertyValue); - } - } -} diff --git a/source/java/org/alfresco/cmis/mapping/RootActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/RootActionEvaluator.java deleted file mode 100644 index 718c79d4e5..0000000000 --- a/source/java/org/alfresco/cmis/mapping/RootActionEvaluator.java +++ /dev/null @@ -1,71 +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 . - */ -package org.alfresco.cmis.mapping; - -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Action Evaluator which evaluates on whether node is root or not - * - * @author davidc - */ -public class RootActionEvaluator extends AbstractActionEvaluator -{ - private AbstractActionEvaluator evaluator; - private boolean allow; - - /** - * Construct - * - * @param serviceRegistry - * @param action - */ - protected RootActionEvaluator(AbstractActionEvaluator evaluator, boolean allow) - { - super(evaluator.getServiceRegistry(), evaluator.getAction()); - this.evaluator = evaluator; - this.allow = allow; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef) - */ - public boolean isAllowed(ObjectType id) - { - if ((id instanceof NodeRef) && id.equals(getServiceRegistry().getCMISService().getDefaultRootNodeRef())) - { - return allow; - } - - return evaluator.isAllowed(id); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("RootActionEvaluator[evaluator=").append(evaluator).append(",allow=").append(allow).append("]"); - return builder.toString(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/SourceIdProperty.java b/source/java/org/alfresco/cmis/mapping/SourceIdProperty.java deleted file mode 100644 index 18c209f006..0000000000 --- a/source/java/org/alfresco/cmis/mapping/SourceIdProperty.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.AssociationRef; - -/** - * Accessor for the Source Id (relationship) - * - * @author davidc - */ -public class SourceIdProperty extends AbstractProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public SourceIdProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_SOURCE_ID); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef) - */ - public Serializable getValue(AssociationRef assocRef) - { - return assocRef.getSourceRef().toString(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/TargetIdProperty.java b/source/java/org/alfresco/cmis/mapping/TargetIdProperty.java deleted file mode 100644 index a2382828a3..0000000000 --- a/source/java/org/alfresco/cmis/mapping/TargetIdProperty.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.AssociationRef; - -/** - * Accessor for the Target Id (relationship) - * - * @author davidc - */ -public class TargetIdProperty extends AbstractProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public TargetIdProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_TARGET_ID); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef) - */ - public Serializable getValue(AssociationRef assocRef) - { - return assocRef.getTargetRef().toString(); - } -} diff --git a/source/java/org/alfresco/cmis/mapping/TypeAttributeActionEvaluator.java b/source/java/org/alfresco/cmis/mapping/TypeAttributeActionEvaluator.java deleted file mode 100644 index b58f4597ec..0000000000 --- a/source/java/org/alfresco/cmis/mapping/TypeAttributeActionEvaluator.java +++ /dev/null @@ -1,303 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Map; - -import org.alfresco.cmis.CMISAllowedActionEnum; -import org.alfresco.cmis.CMISInvalidArgumentException; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.util.Pair; -import org.apache.chemistry.abdera.ext.CMISAllowableActions; - -/** - * This evaluator determines an action availability in accordance with value of object type definition attribute and in accordance with rules of checking of the object type - * definition attribute value. The rules are:
- * - attribute value may be null or it cannot. getSecond() of the {@link TypeAttributeActionEvaluator#comparator} field is ignored, if it cannot be equal - * to null
- *
- * This evaluator is generic, because it is used in the scope of {@link CompositeActionEvaluator}.
- *
- * - * @author Dmitry Velichkevich - * @see TypeAttributeActionEvaluator#comparator - */ -public class TypeAttributeActionEvaluator extends AbstractActionEvaluator -{ - private TypeDefinitionAttributeEnum attribute; - - /** - * This field contains descriptor to extract and compare desired attribute value from object type definition. The following attribute value data types are supported:
- * - descendants of {@link Serializable} interface;
- * - descendants of {@link Collection} interface;
- * - descendatns of {@link Map} interface.
- *
- * Result of the getFirst() method of the comparator field must contain the following value:
- * - this value is completely ignored, if attribute data type is descendant of {@link Serializable};
- * - {@link Integer} number, which determines index of element in collection. Element will be received, using {@link Collection#toArray()}[({@link Integer}) - * comparator.getFirst()];
- * - an appropriate object, which may be used as a key to receive attribute value, if attribute data type is descendant of the {@link Map}
- *
- * Result of getSecond() method of the comparator field MUST NOT be null! This {@link Comparable} instance MUST encapsulate the logic of - * additional processing of extracted actual attribute value (for example, if extracted value has some custom data type), if necessary. And it should encapsulate the logic of - * comparing an actual value of the attribute with the expected. Expected value is also a subject of encapsulation of the {@link Comparable} - */ - private Pair> comparator; - - private boolean nullExpected; - - private boolean defaultAllowing; - - /** - * Constructor - * - * @param attribute - {@link TypeDefinitionAttributeEnum} enumeration value, which specifies method of {@link CMISTypeDefinition} to receive attribute, which should be - * validated - * @param comparator - {@link Pair}<{@link Object}, {@link Comparable}<{@link Object}>> instance. See {@link TypeAttributeActionEvaluator#comparator} for more - * details - * @param nullExpected - {@link Boolean} value, which determines: true - attribute value may be null, false - attribute value can't be - * equal to null (this leads to ignoring getSecond() of the {@link TypeAttributeActionEvaluator#comparator} field) - * @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 TypeAttributeActionEvaluator(TypeDefinitionAttributeEnum attribute, Pair> comparator, boolean nullExpected, boolean defaultAllowing, - ServiceRegistry serviceRegistry, CMISAllowedActionEnum action) - { - super(serviceRegistry, action); - this.attribute = attribute; - this.comparator = comparator; - this.nullExpected = nullExpected; - this.defaultAllowing = defaultAllowing; - } - - @Override - public boolean isAllowed(ObjectType object) - { - boolean result = defaultAllowing; - - if ((null != object) && (null != attribute) && (null != comparator) && (null != comparator.getSecond())) - { - CMISTypeDefinition typeDefinition = null; - - try - { - typeDefinition = getServiceRegistry().getCMISService().getTypeDefinition(object); - } - catch (CMISInvalidArgumentException e) - { - throw new RuntimeException(e.toString(), e); - } - - result = attribute.satisfies(typeDefinition, comparator, nullExpected, defaultAllowing); - } - - return result; - } - - /** - * This enumeration encapsulates the logic of object type definition attributes comparing. It uses Java Reflection mechanism to get actual attribute value, which should be - * validated - * - * @author Dmitry Velichkevich - */ - public static enum TypeDefinitionAttributeEnum - { - /** - * {@link CMISTypeDefinition#isPublic()} - */ - PUBLIC("isPublic", true), - - /** - * {@link CMISTypeDefinition#getTypeId()} - */ - TYPE_ID("getTypeId", true), - - /** - * {@link CMISTypeDefinition#getQueryName()} - */ - QUERY_NAME("getQueryName", true), - - /** - * {@link CMISTypeDefinition#getDisplayName()} - */ - DISPLAY_NAME("getDisplayName", true), - - /** - * {@link CMISTypeDefinition#getParentType()} - */ - PARENT_TYPE("getParentType", false), - - /** - * {@link CMISTypeDefinition#getSubTypes(boolean)} - */ - SUB_TYPES("getSubTypes", false), - - /** - * {@link CMISTypeDefinition#getBaseType()} - */ - BASE_TYPE("getBaseType", false), - - /** - * {@link CMISTypeDefinition#getDescription()} - */ - DESCRIPTION("getDescription", true), - - /** - * {@link CMISTypeDefinition#isCreatable()} - */ - CREATABLE("isCreatable", true), - - /** - * {@link CMISTypeDefinition#isFileable()} - */ - FILEABLE("isFileable", true), - - /** - * {@link CMISTypeDefinition#isQueryable()} - */ - QUERYABLE("isQueryable", true), - - /** - * {@link CMISTypeDefinition#isFullTextIndexed()} - */ - FULL_TEXT_INDEXED("isFullTextIndexed", true), - - /** - * {@link CMISTypeDefinition#isControllablePolicy()} - */ - CONTROLLABLE_POLICY("isControllablePolicy", true), - - /** - * {@link CMISTypeDefinition#isControllableACL()} - */ - CONTROLLABLE_ACL("isControllableACL", true), - - /** - * {@link CMISTypeDefinition#isIncludedInSuperTypeQuery()} - */ - INCLUDED_IN_SUPER_TYPE_QUERY("isIncludedInSuperTypeQuery", true), - - /** - * {@link CMISTypeDefinition#isVersionable()} - */ - VERSIONABLE("isVersionable", true), - - /** - * {@link CMISTypeDefinition#getContentStreamAllowed()} - */ - CONTENT_STREAM_ALLOWED("getContentStreamAllowed", true), - - /** - * {@link CMISTypeDefinition#getAllowedSourceTypes()} - */ - ALLOWED_SOURCE_TYPES("getAllowedSourceTypes", false), - - /** - * {@link CMISTypeDefinition#getAllowedTargetTypes()} - */ - ALLOWED_TARGET_TYPES("getAllowedTargetTypes", false), - - /** - * {@link CMISTypeDefinition#getPropertyDefinitions()} - */ - PROPERTY_DEFINITIONS("getPropertyDefinitions", false), - - /** - * {@link CMISTypeDefinition#getOwnedPropertyDefinitions()} - */ - OWNED_PROPERTY_DEFINITIONS("getOwnedPropertyDefinitions", false); - - private String methodName; - - private boolean primitiveType; - - /** - * Constructor - * - * @param methodName - {@link String} value, which specifies name of the method, which returns desired attribute value - * @param primitiveType - {@link Boolean} value, which determines: true - attribute value data type IS NOT descendant of {@link Collection} or {@link Map}, - * false - attribute value data type IS descendant of {@link Collection} or {@link Map} - */ - private TypeDefinitionAttributeEnum(String methodName, boolean primitiveType) - { - this.methodName = methodName; - this.primitiveType = primitiveType; - } - - /** - * This method determines, if object data type definition contains attribute, which satisfies to condition to allow some action - * - * @param typeDefinition - {@link CMISTypeDefinition} instance of the object, which should be checked - * @param comparator - {@link Pair}<{@link Object}, {@link Comparable}<{@link Object}>> instance. See {@link TypeAttributeActionEvaluator#comparator} for more - * details - * @param nullExpected - {@link Boolean} value, which determines: true - attribute value may be null, false - attribute value can't - * be equal to null (this leads to ignoring getSecond() of the comparator attribute) - * @param defaultAllowing - {@link Boolean} value, which determines availability of action for several special cases (invalid object id, empty collection of the aspects - * etc.) - * @return - {@link Boolean} value, which determines: true - actual attribute value satisfies all the conditions of the comparator parameter, - * false - actual attribute value doesn't satisfy conditions of the comparator parameter - */ - @SuppressWarnings("rawtypes") - public boolean satisfies(CMISTypeDefinition typeDefinition, Pair> comparator, boolean nullExpected, boolean defaultAllowing) - { - if (null == typeDefinition) - { - return defaultAllowing; - } - - Object actualValue = null; - try - { - actualValue = typeDefinition.getClass().getMethod(methodName).invoke(typeDefinition); - } - catch (Exception e) - { - throw new RuntimeException("Interface of '" + CMISTypeDefinition.class.getName() + "' has been modified!"); - } - - if ((null == actualValue) && !primitiveType) - { - return defaultAllowing; - } - - if (actualValue instanceof Map) - { - actualValue = ((Map) actualValue).get(comparator.getFirst()); - } - else - { - if (actualValue instanceof Collection) - { - actualValue = ((Collection) actualValue).toArray()[(Integer) comparator.getFirst()]; - } - } - - if (!nullExpected) - { - return null != actualValue; - } - - return 0 == comparator.getSecond().compareTo(actualValue); - } - } -} diff --git a/source/java/org/alfresco/cmis/mapping/VersionLabelProperty.java b/source/java/org/alfresco/cmis/mapping/VersionLabelProperty.java deleted file mode 100644 index e32f8bb8eb..0000000000 --- a/source/java/org/alfresco/cmis/mapping/VersionLabelProperty.java +++ /dev/null @@ -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 . - */ -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; - -/** - * @author dward - */ -public class VersionLabelProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public VersionLabelProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_LABEL); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - if (isWorkingCopy(nodeRef)) - { - return "pwc"; - } - Serializable versionLabel = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL); - if (versionLabel == null) - { - return "0.0"; - } - return versionLabel; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutByProperty.java b/source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutByProperty.java deleted file mode 100644 index 669e2a7d28..0000000000 --- a/source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutByProperty.java +++ /dev/null @@ -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 . - */ -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; - -/** - * Get the CMIS version series checked out by property - * - * @author dward - */ -public class VersionSeriesCheckedOutByProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public VersionSeriesCheckedOutByProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - NodeRef versionSeries; - if (isWorkingCopy(nodeRef)) - { - return getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_OWNER); - } - else if (hasWorkingCopy((versionSeries = getVersionSeries(nodeRef)))) - { - return getServiceRegistry().getNodeService().getProperty(versionSeries, ContentModel.PROP_LOCK_OWNER); - } - return null; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutIdProperty.java b/source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutIdProperty.java deleted file mode 100644 index 88f21e1854..0000000000 --- a/source/java/org/alfresco/cmis/mapping/VersionSeriesCheckedOutIdProperty.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * Get the CMIS version series checked out id property - * - * @author dward - */ -public class VersionSeriesCheckedOutIdProperty extends AbstractVersioningProperty -{ - /** - * Construct - * - * @param serviceRegistry - */ - public VersionSeriesCheckedOutIdProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef) - */ - public Serializable getValue(NodeRef nodeRef) - { - NodeRef versionSeries; - if (isWorkingCopy(nodeRef)) - { - return nodeRef.toString(); - } - else if (hasWorkingCopy((versionSeries = getVersionSeries(nodeRef)))) - { - NodeRef pwc = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(versionSeries); - if (pwc != null) - { - return pwc.toString(); - } - } - return null; - } -} diff --git a/source/java/org/alfresco/cmis/mapping/VersionSeriesIdProperty.java b/source/java/org/alfresco/cmis/mapping/VersionSeriesIdProperty.java deleted file mode 100644 index a8c9202d6d..0000000000 --- a/source/java/org/alfresco/cmis/mapping/VersionSeriesIdProperty.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; - -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.coci.CheckOutCheckInService; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * @author dward - */ -public class VersionSeriesIdProperty extends AbstractVersioningProperty -{ - /** - * Construct - */ - public VersionSeriesIdProperty(ServiceRegistry serviceRegistry) - { - super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_SERIES_ID); - } - - @Override - public Serializable getValue(NodeRef nodeRef) - { - CheckOutCheckInService checkOutCheckInService = getServiceRegistry().getCheckOutCheckInService(); - NodeRef result = null; - if (checkOutCheckInService.isWorkingCopy(nodeRef)) - { - result = checkOutCheckInService.getCheckedOut(nodeRef); - if (result == null) - { - result = nodeRef; - } - } - else - { - result = getVersionSeries(nodeRef); - } - return result.toString(); - } -} diff --git a/source/java/org/alfresco/cmis/renditions/CMISRenditionImpl.java b/source/java/org/alfresco/cmis/renditions/CMISRenditionImpl.java deleted file mode 100644 index 96eac8bebd..0000000000 --- a/source/java/org/alfresco/cmis/renditions/CMISRenditionImpl.java +++ /dev/null @@ -1,266 +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 . - */ -package org.alfresco.cmis.renditions; - -import org.alfresco.cmis.CMISRendition; -import org.alfresco.service.cmr.repository.NodeRef; - -/** - * CMIS Rendition Implementation - * - * @author Stas Sokolovsky - */ -public class CMISRenditionImpl implements CMISRendition -{ - private NodeRef nodeRef; - private String streamId; - private String mimeType; - private String kind; - private Integer height; - private Integer width; - private String title; - private Integer length; - private String renditionDocumentId; - - /** - * Construct a CmisRendition using fields - * - * @param nodeRef the rendition node reference - * @param streamId rendition stream id - * @param mimeType the MIME type of the rendition stream - * @param kind a categorization String associated with the rendition - * @param height the height of image - * @param width the width of image - * @param title rendition title - * @param length the length of the rendition stream in bytes - * @param renditionDocumentId the rendition document id - */ - public CMISRenditionImpl(NodeRef nodeRef, String streamId, String mimeType, String kind, Integer height, Integer width, String title, Integer length, String renditionDocumentId) - { - super(); - this.nodeRef = nodeRef; - this.streamId = streamId; - this.mimeType = mimeType; - this.kind = kind; - this.height = height; - this.width = width; - this.title = title; - this.length = length; - this.renditionDocumentId = renditionDocumentId; - } - - /** - * Default constructor - */ - public CMISRenditionImpl() - { - super(); - } - - /** - * @see org.alfresco.cmis.CMISRendition#getStreamId() - */ - public String getStreamId() - { - return streamId; - } - - /** - * Set the rendition stream id - * - * @param streamId rendition stream id - */ - public void setStreamId(String streamId) - { - this.streamId = streamId; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getMimeType() - */ - public String getMimeType() - { - return mimeType; - } - - /** - * Set the MIME type of the rendition stream - * - * @param mimeType the MIME type of the rendition stream - */ - public void setMimeType(String mimeType) - { - this.mimeType = mimeType; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getKind() - */ - public String getKind() - { - return kind; - } - - /** - * Set rendition kind - * - * @param kind rendition kind - */ - public void setKind(String kind) - { - this.kind = kind; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getHeight() - */ - public Integer getHeight() - { - return height; - } - - /** - * Set the height of image - * - * @param height the height of image - */ - public void setHeight(Integer height) - { - this.height = height; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getWidth() - */ - public Integer getWidth() - { - return width; - } - - /** - * Set the width of image - * - * @param width the width of image - */ - public void setWidth(Integer width) - { - this.width = width; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getTitle() - */ - public String getTitle() - { - return title; - } - - /** - * Set the title of rendition - * - * @param title the title - */ - public void setTitle(String title) - { - this.title = title; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getLength() - */ - public Integer getLength() - { - return length; - } - - /** - * Set the length of the rendition stream in bytes - * - * @param length length of the rendition stream in bytes - */ - public void setLength(Integer length) - { - this.length = length; - } - - /** - * @see org.alfresco.cmis.CMISRendition#getRenditionDocumentId() - */ - public String getRenditionDocumentId() - { - return renditionDocumentId; - } - - /** - * Set the rendition document id - * - * @param renditionDocumentId the rendition document id - */ - public void setRenditionDocumentId(String renditionDocumentId) - { - this.renditionDocumentId = renditionDocumentId; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.CMISRendition#getNodeRef() - */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - /** - * @param nodeRef - * the nodeRef to set - */ - public void setNodeRef(NodeRef nodeRef) - { - this.nodeRef = nodeRef; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj instanceof CMISRendition) - { - CMISRendition that = (CMISRendition) obj; - return (this.getStreamId() != null && that.getStreamId() != null && this.getStreamId().equals(that.getStreamId())); - } - else - { - return false; - } - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return this.getStreamId() != null ? this.getStreamId().hashCode() : 0x01; - } - -} diff --git a/source/java/org/alfresco/cmis/renditions/CMISRenditionServiceImpl.java b/source/java/org/alfresco/cmis/renditions/CMISRenditionServiceImpl.java deleted file mode 100644 index 83a2922b95..0000000000 --- a/source/java/org/alfresco/cmis/renditions/CMISRenditionServiceImpl.java +++ /dev/null @@ -1,502 +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 . - */ -package org.alfresco.cmis.renditions; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - -import org.alfresco.cmis.CMISFilterNotValidException; -import org.alfresco.cmis.CMISRendition; -import org.alfresco.cmis.CMISRenditionService; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.model.RenditionModel; -import org.alfresco.repo.content.transform.magick.ImageResizeOptions; -import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; -import org.alfresco.repo.thumbnail.ThumbnailDefinition; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.thumbnail.ThumbnailService; -import org.alfresco.service.namespace.RegexQNamePattern; - -/** - * Rendition Service Implementation - * - * @author Stas Sokolovsky - */ -public class CMISRenditionServiceImpl implements CMISRenditionService -{ - - /** Rendition filter constants */ - private static final String FILTER_WILDCARD = "*"; - private static final String FILTER_NONE = "cmis:none"; - private static final String FILTER_DELIMITER = ","; - private static final String SUBTYPES_POSTFIX = "/*"; - private static final String SUBTYPES_DELIMITER = "/"; - - /** Service dependencies */ - private ThumbnailService thumbnailService; - private NodeService nodeService; - - /** Kind to thumbnail mapping */ - private Map> kindToThumbnailNames = new HashMap>(); - private Map thumbnailNamesToKind = new HashMap(); - - /** Custom renditions */ - private CustomRenditionsCache customRenditionsCache; - - /** - * @throws CMISFilterNotValidException - * @see org.alfresco.cmis.CMISRenditionService#getRenditions(org.alfresco.service.cmr.repository.NodeRef, java.lang.String) - */ - public List getRenditions(NodeRef node, String renditionFilter) throws CMISFilterNotValidException - { - Collection result = null; - ThumbnailFilter thumbnailFilter = getThumbnailFilter(renditionFilter); - if (thumbnailFilter != null) - { - result = getRenditions(node, thumbnailFilter); - } - return result != null ? new ArrayList(result) : null; - } - - /** - * Get renditions for a document. - * - * @param node node reference of document - * @param thumbnailFilter thumbnail filter - * @return set of renditions - */ - private Set getRenditions(NodeRef node, ThumbnailFilter thumbnailFilter) - { - Set result = new HashSet(); - if (thumbnailFilter.isAny()) - { - result.addAll(getAllRenditions(node)); - } - else - { - for (String thumbnailName : thumbnailFilter.getThumbnailNames()) - { - CMISRendition rendition = getRenditionByThumbnailName(node, thumbnailName); - if (rendition != null) - { - result.add(rendition); - } - } - for (String mimetype : thumbnailFilter.getMimetypes()) - { - result.addAll(getRenditionByMimetype(node, mimetype)); - } - } - result.addAll(getCustomRenditions(thumbnailFilter)); - return result; - } - - /** - * Get rendition by thumbnail name. - * - * @param node node reference of document - * @param thumbnailName thumbnail name - * @return rendition - */ - private CMISRendition getRenditionByThumbnailName(NodeRef node, String thumbnailName) - { - CMISRendition result = null; - - NodeRef thumbnailNode = thumbnailService.getThumbnailByName(node, ContentModel.PROP_CONTENT, thumbnailName); - - if (thumbnailNode != null) - { - result = getRendition(thumbnailNode, node); - } - return result; - } - - /** - * Get rendition by mimetype. - * - * @param node node reference of document - * @param mimetype rendition mimetype - * @return list of renditions - */ - private List getRenditionByMimetype(NodeRef node, String mimetype) - { - List result = new ArrayList(); - - List thumbnails = thumbnailService.getThumbnails(node, ContentModel.PROP_CONTENT, mimetype, null); - - if (thumbnails != null) - { - for (NodeRef thumbnailNode : thumbnails) - { - CMISRendition rendition = getRendition(thumbnailNode, node); - if (rendition != null) - { - result.add(rendition); - } - } - } - return result; - } - - /** - * Convert the rendition filter to thumbnail filter. - * - * @param renditionFilter rendition filter - * @return thumbnail filter - * @throws CMISFilterNotValidException - */ - private ThumbnailFilter getThumbnailFilter(String renditionFilter) throws CMISFilterNotValidException - { - ThumbnailFilter result = null; - if (renditionFilter != null && !renditionFilter.equals(FILTER_NONE)) - { - // Scan the filter for whitespace, which is disallowed by the spec - for (int i=0; i < renditionFilter.length(); i = renditionFilter.offsetByCodePoints(i, 1)) - { - if (Character.isWhitespace(renditionFilter.codePointAt(i))) - { - throw new CMISFilterNotValidException(renditionFilter); - } - } - result = new ThumbnailFilter(); - if (renditionFilter.equals(FILTER_WILDCARD)) - { - result.setAny(true); - } - else - { - String[] filterElements = renditionFilter.split(FILTER_DELIMITER); - if (filterElements == null || filterElements.length < 1) - { - throw new AlfrescoRuntimeException("Invalid rendition filter"); - } - for (String filterElement : filterElements) - { - filterElement = filterElement.trim(); - if (filterElement.indexOf('/') == -1) - { - result.getKinds().add(filterElement); - List thumbnails = kindToThumbnailNames.get(filterElement); - if (thumbnails != null) - { - result.getThumbnailNames().addAll(thumbnails); - } - } - else - { - result.getMimetypes().add(filterElement); - } - } - } - } - return result; - } - - /** - * Get the thumbnail definition. - * - * @param thumbnailName thumbnail name - * @return thumbnail definition - */ - private ThumbnailDefinition getThumbnailDefinition(String thumbnailName) - { - return thumbnailService.getThumbnailRegistry().getThumbnailDefinition(thumbnailName); - } - - /** - * Get the image attributes of thumbnail. - * - * @param thumbnailName thumbnail name - * @return image attributes - */ - private ImageResizeOptions getImageAttributes(String thumbnailName) - { - ThumbnailDefinition thumbnailDefinition = getThumbnailDefinition(thumbnailName); - if (thumbnailDefinition != null && thumbnailDefinition.getTransformationOptions() != null - && thumbnailDefinition.getTransformationOptions() instanceof ImageTransformationOptions) - { - return ((ImageTransformationOptions) thumbnailDefinition.getTransformationOptions()).getResizeOptions(); - } - return null; - } - - /** - * Create CMISRendition by thumbnailNode and documentNode. - * - * @param thumbnailNode thumbnail node reference - * @param documentNode document node reference - * @return CMISRendition - */ - private CMISRendition getRendition(NodeRef thumbnailNode, NodeRef documentNode) - { - CMISRenditionImpl rendition = null; - - String thumbnailName = getThumbnailName(thumbnailNode); - String kind = thumbnailNamesToKind.get(thumbnailName); - kind = (kind == null) ? thumbnailName : kind; - - rendition = new CMISRenditionImpl(); - ContentData contentData = (ContentData) nodeService.getProperty(thumbnailNode, ContentModel.PROP_CONTENT); - rendition.setNodeRef(thumbnailNode); - rendition.setStreamId(thumbnailNode.toString()); - rendition.setRenditionDocumentId(documentNode.toString()); - rendition.setTitle(thumbnailName); - rendition.setKind(kind); - rendition.setMimeType(contentData.getMimetype()); - rendition.setLength((int) contentData.getSize()); - - ImageResizeOptions imageAttributes = getImageAttributes(thumbnailName); - if (imageAttributes != null) - { - rendition.setWidth(imageAttributes.getWidth()); - rendition.setHeight(imageAttributes.getHeight()); - } - return rendition; - } - - private String getThumbnailName(NodeRef thumbnailNode) - { - String thumbnailName = null; - List parentAssocs = nodeService.getParentAssocs(thumbnailNode, - RenditionModel.ASSOC_RENDITION, RegexQNamePattern.MATCH_ALL); - if (parentAssocs.size() == 1) { - ChildAssociationRef parentAssoc = parentAssocs.get(0); - thumbnailName = parentAssoc.getQName().getLocalName(); - } - return thumbnailName; - } - - /** - * Get custom renditions. - * - * @param thumbnailFilter thumbnail filter - * @return list of renditions - */ - private List getCustomRenditions(ThumbnailFilter filter) - { - List result = new ArrayList(); - if (customRenditionsCache != null) - { - if (filter.isAny()) - { - result.addAll(customRenditionsCache.getAllRenditions()); - } - else - { - for (String kind : filter.getKinds()) - { - List renditions = customRenditionsCache.getRenditionsByKind(kind); - if (renditions != null) - { - result.addAll(renditions); - } - } - for (String mimetype : filter.getMimetypes()) - { - List renditions = customRenditionsCache.getRenditionsByMimeType(mimetype); - if (renditions != null) - { - result.addAll(renditions); - } - } - } - } - return result; - } - - /** - * Get all renditions for a document. - * - * @param node document node ref - * @return list of renditions - */ - private List getAllRenditions(NodeRef node) - { - return getRenditionByMimetype(node, null); - } - - /** - * Set rendition kind mapping. - * - * @param RenditionKind to Thumbnail Definition mapping - */ - public void setRenditionKindMapping(Map> renditionKinds) - { - this.kindToThumbnailNames = renditionKinds; - for (Entry> entry : renditionKinds.entrySet()) - { - for (String thumbnailName : entry.getValue()) - { - thumbnailNamesToKind.put(thumbnailName, entry.getKey()); - } - } - } - - /** - * Set custom renditions. - * - * @param renditions list of renditions - */ - public void setCustomRenditions(List renditions) - { - this.customRenditionsCache = new CustomRenditionsCache(renditions); - } - - /** - * Set the NodeService. - * - * @param nodeService NodeService - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * Set the ThumbnailService. - * - * @param thumbnailService thumbnailService - */ - public void setThumbnailService(ThumbnailService thumbnailService) - { - this.thumbnailService = thumbnailService; - } - - /** - * Cache that aggregates renditions informaition to allow fast searching by kind and mimetype - */ - private class CustomRenditionsCache - { - private Map> renditionsByKind; - private Map> renditionsByMimeType; - private Map> renditionsByBaseMimeType; - private List allRenditions; - - public CustomRenditionsCache(List renditions) - { - allRenditions = renditions; - renditionsByKind = new HashMap>(renditions.size()); - renditionsByMimeType = new HashMap>(renditions.size()); - renditionsByBaseMimeType = new HashMap>(renditions.size()); - for (CMISRendition rendition : renditions) - { - String baseType = getBaseType(rendition.getMimeType()); - if (!renditionsByKind.containsKey(rendition.getKind())) - { - renditionsByKind.put(rendition.getKind(), new ArrayList(1)); - } - if (!renditionsByMimeType.containsKey(rendition.getMimeType())) - { - renditionsByMimeType.put(rendition.getMimeType(), new ArrayList(1)); - } - if (!renditionsByBaseMimeType.containsKey(baseType)) - { - renditionsByBaseMimeType.put(baseType, new ArrayList(1)); - } - renditionsByKind.get(rendition.getKind()).add(rendition); - renditionsByMimeType.get(rendition.getMimeType()).add(rendition); - renditionsByBaseMimeType.get(baseType).add(rendition); - } - } - - public List getRenditionsByKind(String kind) - { - return renditionsByKind.get(kind); - } - - public List getRenditionsByMimeType(String mimetype) - { - if (mimetype.endsWith(SUBTYPES_POSTFIX)) - { - String baseMimetype = mimetype.substring(0, mimetype.length() - SUBTYPES_POSTFIX.length()); - return renditionsByBaseMimeType.get(baseMimetype); - } - else - { - return renditionsByMimeType.get(mimetype); - } - } - - public Collection getAllRenditions() - { - return allRenditions; - } - - private String getBaseType(String mimetype) - { - String baseMymetype = mimetype; - int subTypeIndex = mimetype.indexOf(SUBTYPES_DELIMITER); - if (subTypeIndex > 0 || subTypeIndex < mimetype.length()) - { - baseMymetype = mimetype.substring(0, subTypeIndex); - } - return baseMymetype; - } - } - - /** - * Parsed RenditionFilter - */ - private class ThumbnailFilter - { - private List kinds = new ArrayList(); - - private List thumbnailNames = new ArrayList(); - - private List mimetypes = new ArrayList(); - - private boolean any = false; - - public List getThumbnailNames() - { - return thumbnailNames; - } - - public List getMimetypes() - { - return mimetypes; - } - - public List getKinds() - { - return kinds; - } - - public boolean isAny() - { - return any; - } - - public void setAny(boolean any) - { - this.any = any; - } - - } -} diff --git a/source/java/org/alfresco/cmis/search/CMISFTSQueryParser.java b/source/java/org/alfresco/cmis/search/CMISFTSQueryParser.java deleted file mode 100644 index 0437bf2e75..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISFTSQueryParser.java +++ /dev/null @@ -1,417 +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 . - */ -package org.alfresco.cmis.search; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.alfresco.repo.search.adaptor.lucene.AnalysisMode; -import org.alfresco.repo.search.impl.parsers.CMIS_FTSLexer; -import org.alfresco.repo.search.impl.parsers.CMIS_FTSParser; -import org.alfresco.repo.search.impl.parsers.FTSQueryException; -import org.alfresco.repo.search.impl.querymodel.Argument; -import org.alfresco.repo.search.impl.querymodel.Column; -import org.alfresco.repo.search.impl.querymodel.Constraint; -import org.alfresco.repo.search.impl.querymodel.Function; -import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext; -import org.alfresco.repo.search.impl.querymodel.LiteralArgument; -import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; -import org.alfresco.repo.search.impl.querymodel.Selector; -import org.alfresco.repo.search.impl.querymodel.Constraint.Occur; -import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; -import org.alfresco.repo.search.impl.querymodel.impl.functions.FTSPhrase; -import org.alfresco.repo.search.impl.querymodel.impl.functions.FTSTerm; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.antlr.runtime.ANTLRStringStream; -import org.antlr.runtime.CharStream; -import org.antlr.runtime.CommonTokenStream; -import org.antlr.runtime.RecognitionException; -import org.antlr.runtime.Token; -import org.antlr.runtime.tree.CommonTree; -import org.antlr.runtime.tree.Tree; - -public class CMISFTSQueryParser -{ - @SuppressWarnings("unused") - static public Constraint buildFTS(String ftsExpression, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Selector selector, - Map columnMap, String defaultField) - { - // TODO: Decode sql escape for '' should do in CMIS layer - - // parse templates to trees ... - - CMIS_FTSParser parser = null; - try - { - CharStream cs = new ANTLRStringStream(ftsExpression); - CMIS_FTSLexer lexer = new CMIS_FTSLexer(cs); - CommonTokenStream tokens = new CommonTokenStream(lexer); - parser = new CMIS_FTSParser(tokens); - CommonTree ftsNode = (CommonTree) parser.cmisFtsQuery().getTree(); - return buildFTSConnective(ftsNode, factory, functionEvaluationContext, selector, columnMap, defaultField); - } - catch (RecognitionException e) - { - if (parser != null) - { - String[] tokenNames = parser.getTokenNames(); - String hdr = parser.getErrorHeader(e); - String msg = parser.getErrorMessage(e, tokenNames); - throw new FTSQueryException(hdr + "\n" + msg, e); - } - return null; - } - - } - - static private Constraint buildFTSConnective(CommonTree node, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, - Selector selector, Map columnMap, String defaultField) - { - Connective connective; - switch (node.getType()) - { - case CMIS_FTSParser.DISJUNCTION: - connective = Connective.OR; - break; - case CMIS_FTSParser.CONJUNCTION: - connective = Connective.AND; - break; - default: - throw new FTSQueryException("Invalid connective ..." + node.getText()); - } - - List constraints = new ArrayList(node.getChildCount()); - CommonTree testNode; - for (int i = 0; i < node.getChildCount(); i++) - { - CommonTree subNode = (CommonTree) node.getChild(i); - Constraint constraint; - switch (subNode.getType()) - { - case CMIS_FTSParser.DISJUNCTION: - case CMIS_FTSParser.CONJUNCTION: - constraint = buildFTSConnective(subNode, factory, functionEvaluationContext, selector, columnMap, defaultField); - break; - case CMIS_FTSParser.DEFAULT: - testNode = (CommonTree) subNode.getChild(0); - constraint = buildFTSTest(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField); - constraint.setOccur(Occur.DEFAULT); - break; - case CMIS_FTSParser.EXCLUDE: - testNode = (CommonTree) subNode.getChild(0); - constraint = buildFTSTest(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField); - constraint.setOccur(Occur.EXCLUDE); - break; - - default: - throw new FTSQueryException("Unsupported FTS option " + subNode.getText()); - } - constraints.add(constraint); - } - if (constraints.size() == 1) - { - return constraints.get(0); - } - else - { - if (connective == Connective.OR) - { - return factory.createDisjunction(constraints); - } - else - { - return factory.createConjunction(constraints); - } - } - } - - static private Constraint buildFTSTest(CommonTree argNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, - Selector selector, Map columnMap, String defaultField) - { - CommonTree testNode = argNode; - switch (testNode.getType()) - { - case CMIS_FTSParser.DISJUNCTION: - case CMIS_FTSParser.CONJUNCTION: - return buildFTSConnective(testNode, factory, functionEvaluationContext, selector, columnMap, defaultField); - case CMIS_FTSParser.TERM: - return buildTerm(testNode, factory, functionEvaluationContext, selector, columnMap); - case CMIS_FTSParser.PHRASE: - return buildPhrase(testNode, factory, functionEvaluationContext, selector, columnMap); - default: - throw new FTSQueryException("Unsupported FTS option " + testNode.getText()); - } - } - - static private Constraint buildPhrase(CommonTree testNode, QueryModelFactory factory, - FunctionEvaluationContext functionEvaluationContext, Selector selector, Map columnMap) - { - String functionName = FTSPhrase.NAME; - Function function = factory.getFunction(functionName); - Map functionArguments = new LinkedHashMap(); - LiteralArgument larg = factory.createLiteralArgument(FTSPhrase.ARG_PHRASE, DataTypeDefinition.TEXT, getText(testNode.getChild(0))); - functionArguments.put(larg.getName(), larg); - larg = factory.createLiteralArgument(FTSPhrase.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT); - functionArguments.put(larg.getName(), larg); - return factory.createFunctionalConstraint(function, functionArguments); - } - - static private Constraint buildTerm(CommonTree testNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, - Selector selector, Map columnMap) - { - String functionName = FTSTerm.NAME; - Function function = factory.getFunction(functionName); - Map functionArguments = new LinkedHashMap(); - LiteralArgument larg = factory.createLiteralArgument(FTSTerm.ARG_TERM, DataTypeDefinition.TEXT, getText(testNode.getChild(0))); - functionArguments.put(larg.getName(), larg); - larg = factory.createLiteralArgument(FTSTerm.ARG_TOKENISATION_MODE, DataTypeDefinition.ANY, AnalysisMode.DEFAULT); - functionArguments.put(larg.getName(), larg); - return factory.createFunctionalConstraint(function, functionArguments); - } - - - static class DisjunctionToken implements Token - { - - public int getChannel() - { - return 0; - } - - public int getCharPositionInLine() - { - return 0; - } - - public CharStream getInputStream() - { - return null; - } - - public int getLine() - { - return 0; - } - - public String getText() - { - return null; - } - - public int getTokenIndex() - { - return 0; - } - - public int getType() - { - return CMIS_FTSParser.DISJUNCTION; - } - - public void setChannel(int arg0) - { - - - } - - public void setCharPositionInLine(int arg0) - { - - - } - - public void setInputStream(CharStream arg0) - { - - } - - public void setLine(int arg0) - { - - - } - - public void setText(String arg0) - { - - - } - - public void setTokenIndex(int arg0) - { - - } - - public void setType(int arg0) - { - - } - - } - - static class DefaultToken implements Token - { - - public int getChannel() - { - - return 0; - } - - public int getCharPositionInLine() - { - return 0; - } - - public CharStream getInputStream() - { - return null; - } - - public int getLine() - { - return 0; - } - - public String getText() - { - return null; - } - - public int getTokenIndex() - { - return 0; - } - - public int getType() - { - return CMIS_FTSParser.DEFAULT; - } - - public void setChannel(int arg0) - { - - } - - public void setCharPositionInLine(int arg0) - { - - } - - public void setInputStream(CharStream arg0) - { - - } - - public void setLine(int arg0) - { - - } - - public void setText(String arg0) - { - - } - - public void setTokenIndex(int arg0) - { - - } - - public void setType(int arg0) - { - - } - - } - - static private String getText(Tree node) - { - String text = node.getText(); - int index; - switch (node.getType()) - { - case CMIS_FTSParser.FTSWORD: - index = text.indexOf('\\'); - if (index == -1) - { - return text; - } - else - { - return unescape(text); - } - case CMIS_FTSParser.FTSPHRASE: - String phrase = text.substring(1, text.length() - 1); - index = phrase.indexOf('\\'); - if (index == -1) - { - return phrase; - } - else - { - return unescape(phrase); - } - default: - return text; - } - } - - static private String unescape(String string) - { - StringBuilder builder = new StringBuilder(string.length()); - boolean lastWasEscape = false; - - for (int i = 0; i < string.length(); i++) - { - char c = string.charAt(i); - if (lastWasEscape) - { - if (c == 'u') - { - throw new UnsupportedOperationException(string); - } - else - { - builder.append(c); - } - lastWasEscape = false; - } - else - { - if (c == '\\') - { - lastWasEscape = true; - } - else - { - builder.append(c); - } - } - } - if (lastWasEscape) - { - throw new FTSQueryException("Escape character at end of string " + string); - } - - return builder.toString(); - } -} diff --git a/source/java/org/alfresco/cmis/search/CMISQueryParser.java b/source/java/org/alfresco/cmis/search/CMISQueryParser.java deleted file mode 100644 index d782087f0e..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISQueryParser.java +++ /dev/null @@ -1,1666 +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 . - */ -package org.alfresco.cmis.search; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.alfresco.cmis.CMISDataTypeEnum; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISJoinEnum; -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISQueryException; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISScope; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.repo.search.impl.parsers.CMISLexer; -import org.alfresco.repo.search.impl.parsers.CMISParser; -import org.alfresco.repo.search.impl.parsers.FTSParser; -import org.alfresco.repo.search.impl.parsers.FTSQueryException; -import org.alfresco.repo.search.impl.parsers.FTSQueryParser; -import org.alfresco.repo.search.impl.querymodel.Argument; -import org.alfresco.repo.search.impl.querymodel.ArgumentDefinition; -import org.alfresco.repo.search.impl.querymodel.Column; -import org.alfresco.repo.search.impl.querymodel.Constraint; -import org.alfresco.repo.search.impl.querymodel.Function; -import org.alfresco.repo.search.impl.querymodel.FunctionArgument; -import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext; -import org.alfresco.repo.search.impl.querymodel.JoinType; -import org.alfresco.repo.search.impl.querymodel.ListArgument; -import org.alfresco.repo.search.impl.querymodel.LiteralArgument; -import org.alfresco.repo.search.impl.querymodel.Order; -import org.alfresco.repo.search.impl.querymodel.Ordering; -import org.alfresco.repo.search.impl.querymodel.ParameterArgument; -import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.repo.search.impl.querymodel.PropertyArgument; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.repo.search.impl.querymodel.QueryModelException; -import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; -import org.alfresco.repo.search.impl.querymodel.Selector; -import org.alfresco.repo.search.impl.querymodel.SelectorArgument; -import org.alfresco.repo.search.impl.querymodel.Source; -import org.alfresco.repo.search.impl.querymodel.Constraint.Occur; -import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; -import org.alfresco.repo.search.impl.querymodel.impl.BaseComparison; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Child; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Descendant; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Equals; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Exists; -import org.alfresco.repo.search.impl.querymodel.impl.functions.GreaterThan; -import org.alfresco.repo.search.impl.querymodel.impl.functions.GreaterThanOrEquals; -import org.alfresco.repo.search.impl.querymodel.impl.functions.In; -import org.alfresco.repo.search.impl.querymodel.impl.functions.LessThan; -import org.alfresco.repo.search.impl.querymodel.impl.functions.LessThanOrEquals; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Like; -import org.alfresco.repo.search.impl.querymodel.impl.functions.NotEquals; -import org.alfresco.repo.search.impl.querymodel.impl.functions.PropertyAccessor; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Score; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.CachingDateFormat; -import org.antlr.runtime.ANTLRStringStream; -import org.antlr.runtime.CharStream; -import org.antlr.runtime.CommonTokenStream; -import org.antlr.runtime.RecognitionException; -import org.antlr.runtime.tree.CommonTree; - -/** - * @author andyh - */ -public class CMISQueryParser -{ - private enum EscapeMode - { - LITERAL, LIKE, CONTAINS; - } - - private CMISQueryOptions options; - - private CMISDictionaryService cmisDictionaryService; - - private CMISJoinEnum joinSupport; - - private CMISScope[] validScopes; - - private boolean hasScore = false; - - private boolean hasContains = false; - - public CMISQueryParser(CMISQueryOptions options, CMISDictionaryService cmisDictionaryService, CMISJoinEnum joinSupport) - { - this.options = options; - this.cmisDictionaryService = cmisDictionaryService; - this.joinSupport = joinSupport; - this.validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES; - } - - @SuppressWarnings("unused") - public Query parse(QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext) - { - - CMISParser parser = null; - try - { - CharStream cs = new ANTLRStringStream(options.getQuery()); - CMISLexer lexer = new CMISLexer(cs); - CommonTokenStream tokens = new CommonTokenStream(lexer); - parser = new CMISParser(tokens); - parser.setStrict(options.getQueryMode() == CMISQueryMode.CMS_STRICT); - CommonTree queryNode = (CommonTree) parser.query().getTree(); - - CommonTree sourceNode = (CommonTree) queryNode.getFirstChildWithType(CMISParser.SOURCE); - Source source = buildSource(sourceNode, joinSupport, factory); - Map selectors = source.getSelectors(); - ArrayList columns = buildColumns(queryNode, factory, selectors, options.getQuery()); - - HashMap columnMap = new HashMap(); - for (Column column : columns) - { - if (columnMap.containsKey(column.getAlias())) - { - throw new CMISQueryException("Duplicate column alias for " + column.getAlias()); - } - else - { - columnMap.put(column.getAlias(), column); - } - } - - ArrayList orderings = buildOrderings(queryNode, factory, selectors, columns); - - Constraint constraint = null; - CommonTree orNode = (CommonTree) queryNode.getFirstChildWithType(CMISParser.DISJUNCTION); - if (orNode != null) - { - constraint = buildDisjunction(orNode, factory, functionEvaluationContext, selectors, columnMap); - } - - Query query = factory.createQuery(columns, source, constraint, orderings); - - // TODO: validate query and use of ID, function arguments matching - // up etc - - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - if (hasScore && !hasContains) - { - throw new CMISQueryException("Function SCORE() used without matching CONTAINS() function"); - } - } - - return query; - } - catch (RecognitionException e) - { - if (parser != null) - { - String[] tokenNames = parser.getTokenNames(); - String hdr = parser.getErrorHeader(e); - String msg = parser.getErrorMessage(e, tokenNames); - throw new CMISQueryException(hdr + "\n" + msg, e); - } - } - throw new CMISQueryException("Failed to parse"); - } - - /** - * @param queryNode - * @param factory - * @param selectors - * @param columns - * @return - */ - private Constraint buildDisjunction(CommonTree orNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Map selectors, - HashMap columnMap) - { - List constraints = new ArrayList(orNode.getChildCount()); - for (int i = 0; i < orNode.getChildCount(); i++) - { - CommonTree andNode = (CommonTree) orNode.getChild(i); - Constraint constraint = buildConjunction(andNode, factory, functionEvaluationContext, selectors, columnMap); - constraints.add(constraint); - } - if (constraints.size() == 1) - { - return constraints.get(0); - } - else - { - return factory.createDisjunction(constraints); - } - } - - /** - * @param andNode - * @param factory - * @param selectors - * @param columns - * @return - */ - private Constraint buildConjunction(CommonTree andNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Map selectors, - HashMap columnMap) - { - List constraints = new ArrayList(andNode.getChildCount()); - for (int i = 0; i < andNode.getChildCount(); i++) - { - CommonTree notNode = (CommonTree) andNode.getChild(i); - Constraint constraint = buildNegation(notNode, factory, functionEvaluationContext, selectors, columnMap); - constraints.add(constraint); - } - if (constraints.size() == 1) - { - return constraints.get(0); - } - else - { - return factory.createConjunction(constraints); - } - } - - /** - * @param notNode - * @param factory - * @param selectors - * @param columns - * @return - */ - private Constraint buildNegation(CommonTree notNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Map selectors, - HashMap columnMap) - { - if (notNode.getType() == CMISParser.NEGATION) - { - Constraint constraint = buildTest((CommonTree) notNode.getChild(0), factory, functionEvaluationContext, selectors, columnMap); - constraint.setOccur(Occur.EXCLUDE); - return constraint; - } - else - { - return buildTest(notNode, factory, functionEvaluationContext, selectors, columnMap); - } - } - - /** - * @param notNode - * @param factory - * @param selectors - * @param columns - * @return - */ - private Constraint buildTest(CommonTree testNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Map selectors, - HashMap columnMap) - { - if (testNode.getType() == CMISParser.DISJUNCTION) - { - return buildDisjunction(testNode, factory, functionEvaluationContext, selectors, columnMap); - } - else - { - return buildPredicate(testNode, factory, functionEvaluationContext, selectors, columnMap); - } - } - - /** - * @param orNode - * @param factory - * @param selectors - * @param columns - * @return - */ - private Constraint buildPredicate(CommonTree predicateNode, QueryModelFactory factory, FunctionEvaluationContext functionEvaluationContext, Map selectors, - Map columnMap) - { - String functionName; - Function function; - CommonTree argNode; - Map functionArguments; - Argument arg; - switch (predicateNode.getType()) - { - case CMISParser.PRED_CHILD: - functionName = Child.NAME; - function = factory.getFunction(functionName); - functionArguments = new LinkedHashMap(); - argNode = (CommonTree) predicateNode.getChild(0); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Child.ARG_PARENT), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - if (predicateNode.getChildCount() > 1) - { - argNode = (CommonTree) predicateNode.getChild(1); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Child.ARG_SELECTOR), factory, selectors, columnMap, false); - if (!arg.isQueryable()) - { - throw new CMISQueryException("The property is not queryable: " + argNode.getText()); - } - functionArguments.put(arg.getName(), arg); - } - return factory.createFunctionalConstraint(function, functionArguments); - case CMISParser.PRED_COMPARISON: - - switch (predicateNode.getChild(2).getType()) - { - case CMISParser.EQUALS: - functionName = Equals.NAME; - function = factory.getFunction(functionName); - break; - case CMISParser.NOTEQUALS: - functionName = NotEquals.NAME; - function = factory.getFunction(functionName); - break; - case CMISParser.GREATERTHAN: - functionName = GreaterThan.NAME; - function = factory.getFunction(functionName); - break; - case CMISParser.GREATERTHANOREQUALS: - functionName = GreaterThanOrEquals.NAME; - function = factory.getFunction(functionName); - break; - case CMISParser.LESSTHAN: - functionName = LessThan.NAME; - function = factory.getFunction(functionName); - break; - case CMISParser.LESSTHANOREQUALS: - functionName = LessThanOrEquals.NAME; - function = factory.getFunction(functionName); - break; - default: - throw new CMISQueryException("Unknown comparison function " + predicateNode.getChild(2).getText()); - } - functionArguments = new LinkedHashMap(); - argNode = (CommonTree) predicateNode.getChild(0); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(BaseComparison.ARG_MODE), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - argNode = (CommonTree) predicateNode.getChild(1); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(BaseComparison.ARG_LHS), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - argNode = (CommonTree) predicateNode.getChild(3); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(BaseComparison.ARG_RHS), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - checkPredicateConditionsForComparisons(function, functionArguments, functionEvaluationContext, columnMap); - return factory.createFunctionalConstraint(function, functionArguments); - case CMISParser.PRED_DESCENDANT: - functionName = Descendant.NAME; - function = factory.getFunction(functionName); - argNode = (CommonTree) predicateNode.getChild(0); - functionArguments = new LinkedHashMap(); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Descendant.ARG_ANCESTOR), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - if (predicateNode.getChildCount() > 1) - { - argNode = (CommonTree) predicateNode.getChild(1); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Descendant.ARG_SELECTOR), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - } - return factory.createFunctionalConstraint(function, functionArguments); - case CMISParser.PRED_EXISTS: - functionName = Exists.NAME; - function = factory.getFunction(functionName); - argNode = (CommonTree) predicateNode.getChild(0); - functionArguments = new LinkedHashMap(); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Exists.ARG_PROPERTY), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - arg = factory.createLiteralArgument(Exists.ARG_NOT, DataTypeDefinition.BOOLEAN, (predicateNode.getChildCount() > 1)); - functionArguments.put(arg.getName(), arg); - // Applies to both single valued and multi-valued properties - no checks required - return factory.createFunctionalConstraint(function, functionArguments); - case CMISParser.PRED_FTS: - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - if (hasContains) - { - throw new CMISQueryException("Only one CONTAINS() function can be included in a single query statement."); - } - } - String ftsExpression = predicateNode.getChild(0).getText(); - ftsExpression = ftsExpression.substring(1, ftsExpression.length() - 1); - ftsExpression = unescape(ftsExpression, EscapeMode.CONTAINS); - Selector selector; - if (predicateNode.getChildCount() > 1) - { - String qualifier = predicateNode.getChild(1).getText(); - selector = selectors.get(qualifier); - if (selector == null) - { - throw new CMISQueryException("No selector for " + qualifier); - } - } - else - { - if (selectors.size() == 1) - { - selector = selectors.get(selectors.keySet().iterator().next()); - } - else - { - throw new CMISQueryException("A selector must be specified when there are two or more selectors"); - } - } - Connective defaultConnective; - Connective defaultFieldConnective; - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - defaultConnective = Connective.AND; - defaultFieldConnective = Connective.AND; - } - else - { - defaultConnective = options.getDefaultFTSConnective(); - defaultFieldConnective = options.getDefaultFTSFieldConnective(); - } - FTSParser.Mode mode; - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - mode = FTSParser.Mode.CMIS; - } - else - { - if (defaultConnective == Connective.AND) - { - mode = FTSParser.Mode.DEFAULT_CONJUNCTION; - } - else - { - mode = FTSParser.Mode.DEFAULT_DISJUNCTION; - } - } - Constraint ftsConstraint; - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - ftsConstraint = CMISFTSQueryParser.buildFTS(ftsExpression, factory, functionEvaluationContext, selector, columnMap, options.getDefaultFieldName()); - } - else - { - ftsConstraint = FTSQueryParser.buildFTS(ftsExpression, factory, functionEvaluationContext, selector, columnMap, mode, defaultFieldConnective, null, options.getDefaultFieldName()); - } - ftsConstraint.setBoost(1000.0f); - hasContains = true; - return ftsConstraint; - case CMISParser.PRED_IN: - functionName = In.NAME; - function = factory.getFunction(functionName); - functionArguments = new LinkedHashMap(); - argNode = (CommonTree) predicateNode.getChild(0); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(In.ARG_MODE), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - argNode = (CommonTree) predicateNode.getChild(1); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(In.ARG_PROPERTY), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - argNode = (CommonTree) predicateNode.getChild(2); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(In.ARG_LIST), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - arg = factory.createLiteralArgument(In.ARG_NOT, DataTypeDefinition.BOOLEAN, (predicateNode.getChildCount() > 3)); - functionArguments.put(arg.getName(), arg); - checkPredicateConditionsForIn(functionArguments, functionEvaluationContext, columnMap); - return factory.createFunctionalConstraint(function, functionArguments); - case CMISParser.PRED_LIKE: - functionName = Like.NAME; - function = factory.getFunction(functionName); - functionArguments = new LinkedHashMap(); - argNode = (CommonTree) predicateNode.getChild(0); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Like.ARG_PROPERTY), factory, selectors, columnMap, false); - functionArguments.put(arg.getName(), arg); - argNode = (CommonTree) predicateNode.getChild(1); - arg = getFunctionArgument(argNode, function.getArgumentDefinition(Like.ARG_EXP), factory, selectors, columnMap, true); - functionArguments.put(arg.getName(), arg); - arg = factory.createLiteralArgument(Like.ARG_NOT, DataTypeDefinition.BOOLEAN, (predicateNode.getChildCount() > 2)); - functionArguments.put(arg.getName(), arg); - checkPredicateConditionsForLike(functionArguments, functionEvaluationContext, columnMap); - return factory.createFunctionalConstraint(function, functionArguments); - default: - return null; - } - } - - private void checkPredicateConditionsForIn(Map functionArguments, FunctionEvaluationContext functionEvaluationContext, Map columnMap) - { - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - PropertyArgument propertyArgument = (PropertyArgument) functionArguments.get(In.ARG_PROPERTY); - LiteralArgument modeArgument = (LiteralArgument) functionArguments.get(In.ARG_MODE); - String modeString = DefaultTypeConverter.INSTANCE.convert(String.class, modeArgument.getValue(functionEvaluationContext)); - PredicateMode mode = PredicateMode.valueOf(modeString); - String propertyName = propertyArgument.getPropertyName(); - - Column column = columnMap.get(propertyName); - if (column != null) - { - // check for function type - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - propertyName = arg.getPropertyName(); - } - else - { - throw new CMISQueryException("Complex column reference not supoprted in LIKE " + propertyName); - } - } - - boolean isMultiValued = functionEvaluationContext.isMultiValued(propertyName); - - switch (mode) - { - case ANY: - if (isMultiValued) - { - break; - } - else - { - throw new QueryModelException("Predicate mode " + PredicateMode.ANY + " is not supported for IN and single valued properties"); - } - case SINGLE_VALUED_PROPERTY: - if (isMultiValued) - { - throw new QueryModelException("Predicate mode " + PredicateMode.SINGLE_VALUED_PROPERTY + " is not supported for IN and multi-valued properties"); - } - else - { - break; - } - default: - throw new QueryModelException("Unsupported predicate mode " + mode); - } - - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(propertyName); - if (propDef.getDataType() == CMISDataTypeEnum.BOOLEAN) - { - - throw new QueryModelException("In is not supported for properties of type Boolean"); - - } - } - - } - - private void checkPredicateConditionsForComparisons(Function function, Map functionArguments, FunctionEvaluationContext functionEvaluationContext, - Map columnMap) - { - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - ((BaseComparison) function).setPropertyAndStaticArguments(functionArguments); - String propertyName = ((BaseComparison) function).getPropertyName(); - LiteralArgument modeArgument = (LiteralArgument) functionArguments.get(BaseComparison.ARG_MODE); - String modeString = DefaultTypeConverter.INSTANCE.convert(String.class, modeArgument.getValue(functionEvaluationContext)); - PredicateMode mode = PredicateMode.valueOf(modeString); - - Column column = columnMap.get(propertyName); - if (column != null) - { - // check for function type - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - propertyName = arg.getPropertyName(); - } - else - { - throw new CMISQueryException("Complex column reference not supoprted in LIKE " + propertyName); - } - } - - boolean isMultiValued = functionEvaluationContext.isMultiValued(propertyName); - - switch (mode) - { - case ANY: - if (isMultiValued) - { - if (function.getName().equals(Equals.NAME)) - { - break; - } - else - { - throw new QueryModelException("Predicate mode " + PredicateMode.ANY + " is only supported for " + Equals.NAME + " (and multi-valued properties)."); - } - } - else - { - throw new QueryModelException("Predicate mode " + PredicateMode.ANY + " is not supported for " + function.getName() + " and single valued properties"); - } - case SINGLE_VALUED_PROPERTY: - if (isMultiValued) - { - throw new QueryModelException("Predicate mode " - + PredicateMode.SINGLE_VALUED_PROPERTY + " is not supported for " + function.getName() + " and multi-valued properties"); - } - else - { - break; - } - default: - throw new QueryModelException("Unsupported predicate mode " + mode); - } - - // limit support for ID and Boolean - - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(propertyName); - if (propDef.getDataType() == CMISDataTypeEnum.ID) - { - if (function.getName().equals(Equals.NAME) || function.getName().equals(NotEquals.NAME)) - { - return; - } - else - { - throw new QueryModelException("Comparison " + function.getName() + " is not supported for properties of type ID"); - } - } - else if (propDef.getDataType() == CMISDataTypeEnum.BOOLEAN) - { - if (function.getName().equals(Equals.NAME)) - { - return; - } - else - { - throw new QueryModelException("Comparison " + function.getName() + " is not supported for properties of type Boolean"); - } - } - } - - } - - private void checkPredicateConditionsForLike(Map functionArguments, FunctionEvaluationContext functionEvaluationContext, Map columnMap) - { - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - PropertyArgument propertyArgument = (PropertyArgument) functionArguments.get(Like.ARG_PROPERTY); - - boolean isMultiValued = functionEvaluationContext.isMultiValued(propertyArgument.getPropertyName()); - - if (isMultiValued) - { - throw new QueryModelException("Like is not supported for multi-valued properties"); - } - - String cmisPropertyName = propertyArgument.getPropertyName(); - - Column column = columnMap.get(cmisPropertyName); - if (column != null) - { - // check for function type - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - cmisPropertyName = arg.getPropertyName(); - } - else - { - throw new CMISQueryException("Complex column reference not supoprted in LIKE " + cmisPropertyName); - } - } - - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(cmisPropertyName); - if (propDef.getDataType() != CMISDataTypeEnum.STRING) - { - throw new CMISQueryException("LIKE is only supported against String types" + cmisPropertyName); - } - - } - - } - - /** - * @param queryNode - * @param factory - * @param selectors - * @return - */ - private ArrayList buildOrderings(CommonTree queryNode, QueryModelFactory factory, Map selectors, List columns) - { - ArrayList orderings = new ArrayList(); - CommonTree orderNode = (CommonTree) queryNode.getFirstChildWithType(CMISParser.ORDER); - if (orderNode != null) - { - for (int i = 0; i < orderNode.getChildCount(); i++) - { - CommonTree current = (CommonTree) orderNode.getChild(i); - - CommonTree columnRefNode = (CommonTree) current.getFirstChildWithType(CMISParser.COLUMN_REF); - if (columnRefNode != null) - { - String columnName = columnRefNode.getChild(0).getText(); - String qualifier = ""; - if (columnRefNode.getChildCount() > 1) - { - qualifier = columnRefNode.getChild(1).getText(); - } - - Order order = Order.ASCENDING; - - if (current.getChild(1).getType() == CMISParser.DESC) - { - order = Order.DESCENDING; - } - - Column orderColumn = null; - - if (qualifier.length() == 0) - { - Column match = null; - for (Column column : columns) - { - if (column.getAlias().equals(columnName)) - { - match = column; - break; - } - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - String propertyName = arg.getPropertyName(); - if (propertyName.equals(columnName)) - { - match = column; - break; - } - } - } - // in strict mode the ordered column must be selected - if ((options.getQueryMode() == CMISQueryMode.CMS_STRICT) && (match == null)) - { - throw new CMISQueryException("Ordered column is not selected: " + qualifier + "." + columnName); - } - if (match == null) - { - - Selector selector = selectors.get(qualifier); - if (selector == null) - { - if ((qualifier.equals("")) && (selectors.size() == 1)) - { - selector = selectors.get(selectors.keySet().iterator().next()); - } - else - { - throw new CMISQueryException("No selector for " + qualifier); - } - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), CMISScope.DOCUMENT, CMISScope.FOLDER, CMISScope.POLICY); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(columnName); - if (propDef == null) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + "." + columnName); - } - - // Check column/property applies to selector/type - - if (!typeDef.getPropertyDefinitions().containsKey(propDef.getPropertyId().getId())) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + "." + columnName); - } - - // check there is a matching selector - - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - boolean found = false; - for (Column column : columns) - { - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument pa = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - if (pa.getPropertyName().equals(propDef.getPropertyId().getId())) - { - found = true; - break; - } - } - } - if (!found) - { - throw new CMISQueryException("Ordered column is not selected: " + qualifier + "." + columnName); - } - } - - Function function = factory.getFunction(PropertyAccessor.NAME); - Argument arg = factory.createPropertyArgument(PropertyAccessor.ARG_PROPERTY, propDef.isQueryable(), propDef.isOrderable(), selector.getAlias(), propDef - .getPropertyId().getId()); - Map functionArguments = new LinkedHashMap(); - functionArguments.put(arg.getName(), arg); - - String alias = (selector.getAlias().length() > 0) ? selector.getAlias() + "." + propDef.getPropertyId().getId() : propDef.getPropertyId().getId(); - - match = factory.createColumn(function, functionArguments, alias); - } - - orderColumn = match; - } - else - { - Selector selector = selectors.get(qualifier); - if (selector == null) - { - if ((qualifier.equals("")) && (selectors.size() == 1)) - { - selector = selectors.get(selectors.keySet().iterator().next()); - } - else - { - throw new CMISQueryException("No selector for " + qualifier); - } - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), CMISScope.DOCUMENT, CMISScope.FOLDER, CMISScope.POLICY); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(columnName); - if (propDef == null) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + "." + columnName + " selector alias " + selector.getAlias()); - } - - // check there is a matching selector - - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - boolean found = false; - for (Column column : columns) - { - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument pa = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - if (pa.getPropertyName().equals(propDef.getPropertyId().getId())) - { - found = true; - break; - } - } - } - if (!found) - { - throw new CMISQueryException("Ordered column is not selected: " + qualifier + "." + columnName); - } - } - - Function function = factory.getFunction(PropertyAccessor.NAME); - Argument arg = factory.createPropertyArgument(PropertyAccessor.ARG_PROPERTY, propDef.isQueryable(), propDef.isOrderable(), selector.getAlias(), propDef - .getPropertyId().getId()); - Map functionArguments = new LinkedHashMap(); - functionArguments.put(arg.getName(), arg); - - String alias = (selector.getAlias().length() > 0) ? selector.getAlias() + "." + propDef.getPropertyId().getId() : propDef.getPropertyId().getId(); - - orderColumn = factory.createColumn(function, functionArguments, alias); - } - - if (!orderColumn.isOrderable() || !orderColumn.isQueryable()) - { - throw new CMISQueryException("Ordering is not support for " + orderColumn.getAlias()); - } - - Ordering ordering = factory.createOrdering(orderColumn, order); - orderings.add(ordering); - - } - } - } - return orderings; - } - - @SuppressWarnings("unchecked") - private ArrayList buildColumns(CommonTree queryNode, QueryModelFactory factory, Map selectors, String query) - { - ArrayList columns = new ArrayList(); - CommonTree starNode = (CommonTree) queryNode.getFirstChildWithType(CMISParser.ALL_COLUMNS); - if (starNode != null) - { - for (Selector selector : selectors.values()) - { - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - Map propDefs = typeDef.getPropertyDefinitions(); - for (CMISPropertyDefinition definition : propDefs.values()) - { - Function function = factory.getFunction(PropertyAccessor.NAME); - Argument arg = factory.createPropertyArgument(PropertyAccessor.ARG_PROPERTY, definition.isQueryable(), definition.isOrderable(), selector.getAlias(), - definition.getPropertyId().getId()); - Map functionArguments = new LinkedHashMap(); - functionArguments.put(arg.getName(), arg); - String alias = (selector.getAlias().length() > 0) ? selector.getAlias() + "." + definition.getPropertyId().getId() : definition.getPropertyId().getId(); - Column column = factory.createColumn(function, functionArguments, alias); - columns.add(column); - } - } - } - - CommonTree columnsNode = (CommonTree) queryNode.getFirstChildWithType(CMISParser.COLUMNS); - if (columnsNode != null) - { - for (CommonTree columnNode : (List) columnsNode.getChildren()) - { - if (columnNode.getType() == CMISParser.ALL_COLUMNS) - { - String qualifier = columnNode.getChild(0).getText(); - Selector selector = selectors.get(qualifier); - if (selector == null) - { - if ((qualifier.equals("")) && (selectors.size() == 1)) - { - selector = selectors.get(selectors.keySet().iterator().next()); - } - else - { - throw new CMISQueryException("No selector for " + qualifier + " in " + qualifier + ".*"); - } - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - Map propDefs = typeDef.getPropertyDefinitions(); - for (CMISPropertyDefinition definition : propDefs.values()) - { - Function function = factory.getFunction(PropertyAccessor.NAME); - Argument arg = factory.createPropertyArgument(PropertyAccessor.ARG_PROPERTY, definition.isQueryable(), definition.isOrderable(), selector.getAlias(), - definition.getPropertyId().getId()); - Map functionArguments = new LinkedHashMap(); - functionArguments.put(arg.getName(), arg); - String alias = (selector.getAlias().length() > 0) ? selector.getAlias() + "." + definition.getPropertyId().getId() : definition.getPropertyId().getId(); - Column column = factory.createColumn(function, functionArguments, alias); - columns.add(column); - } - } - - if (columnNode.getType() == CMISParser.COLUMN) - { - CommonTree columnRefNode = (CommonTree) columnNode.getFirstChildWithType(CMISParser.COLUMN_REF); - if (columnRefNode != null) - { - String columnName = columnRefNode.getChild(0).getText(); - String qualifier = ""; - if (columnRefNode.getChildCount() > 1) - { - qualifier = columnRefNode.getChild(1).getText(); - } - Selector selector = selectors.get(qualifier); - if (selector == null) - { - if ((qualifier.equals("")) && (selectors.size() == 1)) - { - selector = selectors.get(selectors.keySet().iterator().next()); - } - else - { - throw new CMISQueryException("No selector for " + qualifier); - } - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(columnName); - if (propDef == null) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + " " + columnName); - } - - // Check column/property applies to selector/type - - if (!typeDef.getPropertyDefinitions().containsKey(propDef.getPropertyId().getId())) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + "." + columnName); - } - - Function function = factory.getFunction(PropertyAccessor.NAME); - Argument arg = factory.createPropertyArgument(PropertyAccessor.ARG_PROPERTY, propDef.isQueryable(), propDef.isOrderable(), selector.getAlias(), propDef - .getPropertyId().getId()); - Map functionArguments = new LinkedHashMap(); - functionArguments.put(arg.getName(), arg); - - String alias = (selector.getAlias().length() > 0) ? selector.getAlias() + "." + propDef.getPropertyId().getId() : propDef.getPropertyId().getId(); - if (columnNode.getChildCount() > 1) - { - alias = columnNode.getChild(1).getText(); - } - - Column column = factory.createColumn(function, functionArguments, alias); - columns.add(column); - - } - - CommonTree functionNode = (CommonTree) columnNode.getFirstChildWithType(CMISParser.FUNCTION); - if (functionNode != null) - { - CommonTree functionNameNode = (CommonTree) functionNode.getChild(0); - Function function = factory.getFunction(functionNameNode.getText()); - if (function == null) - { - throw new CMISQueryException("Unknown function: " + functionNameNode.getText()); - } - Collection definitions = function.getArgumentDefinitions().values(); - Map functionArguments = new LinkedHashMap(); - - int childIndex = 2; - for (ArgumentDefinition definition : definitions) - { - if (functionNode.getChildCount() > childIndex + 1) - { - CommonTree argNode = (CommonTree) functionNode.getChild(childIndex++); - Argument arg = getFunctionArgument(argNode, definition, factory, selectors, null, function.getName().equals(Like.NAME)); - functionArguments.put(arg.getName(), arg); - } - else - { - if (definition.isMandatory()) - { - // throw new - // CMISQueryException("Insufficient aruments - // for function " + - // ((CommonTree) - // functionNode.getChild(0)).getText() ); - break; - } - else - { - // ok - } - } - } - - CommonTree rparenNode = (CommonTree) functionNode.getChild(functionNode.getChildCount() - 1); - - int start = getStringPosition(query, functionNode.getLine(), functionNode.getCharPositionInLine()); - int end = getStringPosition(query, rparenNode.getLine(), rparenNode.getCharPositionInLine()); - - if (function.getName().equals(Score.NAME)) - { - hasScore = true; - } - - String alias; - if (function.getName().equals(Score.NAME)) - { - alias = "SEARCH_SCORE"; - // check no args - if (functionNode.getChildCount() > 3) - { - throw new CMISQueryException("The function SCORE() is not allowed any arguments"); - } - } - else - { - alias = query.substring(start, end + 1); - } - if (columnNode.getChildCount() > 1) - { - alias = columnNode.getChild(1).getText(); - } - - Column column = factory.createColumn(function, functionArguments, alias); - columns.add(column); - } - } - } - } - - return columns; - } - - /** - * @param query - * @param line - * @param charPositionInLine - * @return - */ - private int getStringPosition(String query, int line, int charPositionInLine) - { - StringTokenizer tokenizer = new StringTokenizer(query, "\n\r\f"); - String[] lines = new String[tokenizer.countTokens()]; - int i = 0; - while (tokenizer.hasMoreElements()) - { - lines[i++] = tokenizer.nextToken(); - } - - int position = 0; - for (i = 0; i < line - 1; i++) - { - position += lines[i].length(); - position++; - } - return position + charPositionInLine; - } - - private Argument getFunctionArgument(CommonTree argNode, ArgumentDefinition definition, QueryModelFactory factory, Map selectors, - Map columnMap, boolean inLike) - { - if (argNode.getType() == CMISParser.COLUMN_REF) - { - PropertyArgument arg = buildColumnReference(definition.getName(), argNode, factory, selectors, columnMap); - if (!arg.isQueryable()) - { - throw new CMISQueryException("Column refers to unqueryable property " + arg.getPropertyName()); - } - if (!selectors.containsKey(arg.getSelector())) - { - throw new CMISQueryException("No table with alias " + arg.getSelector()); - } - return arg; - } - else if (argNode.getType() == CMISParser.ID) - { - String id = argNode.getText(); - if (selectors.containsKey(id)) - { - SelectorArgument arg = factory.createSelectorArgument(definition.getName(), id); - if (!arg.isQueryable()) - { - throw new CMISQueryException("Selector is not queryable " + arg.getSelector()); - } - return arg; - } - else - { - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(id); - if (propDef == null || !propDef.isQueryable()) - { - throw new CMISQueryException("Column refers to unqueryable property " + definition.getName()); - } - PropertyArgument arg = factory.createPropertyArgument(definition.getName(), propDef.isQueryable(), propDef.isOrderable(), "", propDef.getPropertyId().getId()); - return arg; - } - } - else if (argNode.getType() == CMISParser.PARAMETER) - { - ParameterArgument arg = factory.createParameterArgument(definition.getName(), argNode.getText()); - if (!arg.isQueryable()) - { - throw new CMISQueryException("Parameter is not queryable " + arg.getParameterName()); - } - return arg; - } - else if (argNode.getType() == CMISParser.NUMERIC_LITERAL) - { - CommonTree literalNode = (CommonTree) argNode.getChild(0); - if (literalNode.getType() == CMISParser.FLOATING_POINT_LITERAL) - { - QName type = DataTypeDefinition.DOUBLE; - Number value = Double.parseDouble(literalNode.getText()); - if (value.floatValue() == value.doubleValue()) - { - type = DataTypeDefinition.FLOAT; - value = Float.valueOf(value.floatValue()); - } - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), type, value); - return arg; - } - else if (literalNode.getType() == CMISParser.DECIMAL_INTEGER_LITERAL) - { - QName type = DataTypeDefinition.LONG; - Number value = Long.parseLong(literalNode.getText()); - if (value.intValue() == value.longValue()) - { - type = DataTypeDefinition.INT; - value = Integer.valueOf(value.intValue()); - } - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), type, value); - return arg; - } - else - { - throw new CMISQueryException("Invalid numeric literal " + literalNode.getText()); - } - } - else if (argNode.getType() == CMISParser.STRING_LITERAL) - { - String text = argNode.getChild(0).getText(); - text = text.substring(1, text.length() - 1); - text = unescape(text, inLike ? EscapeMode.LIKE : EscapeMode.LITERAL); - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), DataTypeDefinition.TEXT, text); - return arg; - } - else if (argNode.getType() == CMISParser.DATETIME_LITERAL) - { - String text = argNode.getChild(0).getText(); - text = text.substring(1, text.length() - 1); - StringBuilder builder = new StringBuilder(); - if (text.endsWith("Z")) - { - builder.append(text.substring(0, text.length() - 1)); - builder.append("+0000"); - } - else - { - if (text.charAt(text.length() - 3) != ':') - { - throw new CMISQueryException("Invalid datetime literal " + text); - } - // remove TZ colon .... - builder.append(text.substring(0, text.length() - 3)); - builder.append(text.substring(text.length() - 2, text.length())); - } - text = builder.toString(); - - SimpleDateFormat df = CachingDateFormat.getCmisSqlDatetimeFormat(); - Date date; - try - { - date = df.parse(text); - } - catch (ParseException e) - { - throw new CMISQueryException("Invalid datetime literal " + text); - } - // Convert back :-) - String alfrescoDate = DefaultTypeConverter.INSTANCE.convert(String.class, date); - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), DataTypeDefinition.TEXT, alfrescoDate); - return arg; - } - else if (argNode.getType() == CMISParser.BOOLEAN_LITERAL) - { - String text = argNode.getChild(0).getText(); - if (text.equalsIgnoreCase("TRUE") || text.equalsIgnoreCase("FALSE")) - { - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), DataTypeDefinition.TEXT, text); - return arg; - } - else - { - throw new CMISQueryException("Invalid boolean literal " + text); - } - - } - else if (argNode.getType() == CMISParser.LIST) - { - ArrayList arguments = new ArrayList(); - for (int i = 0; i < argNode.getChildCount(); i++) - { - CommonTree arg = (CommonTree) argNode.getChild(i); - arguments.add(getFunctionArgument(arg, definition, factory, selectors, columnMap, inLike)); - } - ListArgument arg = factory.createListArgument(definition.getName(), arguments); - if (!arg.isQueryable()) - { - throw new CMISQueryException("Not all members of the list are queryable"); - } - return arg; - } - else if (argNode.getType() == CMISParser.ANY) - { - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), DataTypeDefinition.TEXT, argNode.getText()); - return arg; - } - else if (argNode.getType() == CMISParser.SINGLE_VALUED_PROPERTY) - { - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), DataTypeDefinition.TEXT, argNode.getText()); - return arg; - } - else if (argNode.getType() == CMISParser.NOT) - { - LiteralArgument arg = factory.createLiteralArgument(definition.getName(), DataTypeDefinition.TEXT, argNode.getText()); - return arg; - } - else if (argNode.getType() == CMISParser.FUNCTION) - { - CommonTree functionNameNode = (CommonTree) argNode.getChild(0); - Function function = factory.getFunction(functionNameNode.getText()); - if (function == null) - { - throw new CMISQueryException("Unknown function: " + functionNameNode.getText()); - } - Collection definitions = function.getArgumentDefinitions().values(); - Map functionArguments = new LinkedHashMap(); - - int childIndex = 2; - for (ArgumentDefinition currentDefinition : definitions) - { - if (argNode.getChildCount() > childIndex + 1) - { - CommonTree currentArgNode = (CommonTree) argNode.getChild(childIndex++); - Argument arg = getFunctionArgument(currentArgNode, currentDefinition, factory, selectors, columnMap, inLike); - functionArguments.put(arg.getName(), arg); - } - else - { - if (definition.isMandatory()) - { - // throw new CMISQueryException("Insufficient aruments - // for function " + ((CommonTree) - // functionNode.getChild(0)).getText() ); - break; - } - else - { - // ok - } - } - } - FunctionArgument arg = factory.createFunctionArgument(definition.getName(), function, functionArguments); - if (!arg.isQueryable()) - { - throw new CMISQueryException("Not all function arguments refer to orderable arguments: " + arg.getFunction().getName()); - } - return arg; - } - else - { - throw new CMISQueryException("Invalid function argument " + argNode.getText()); - } - } - - @SuppressWarnings("unchecked") - private Source buildSource(CommonTree source, CMISJoinEnum joinSupport, QueryModelFactory factory) - { - if (source.getChildCount() == 1) - { - // single table reference - CommonTree singleTableNode = (CommonTree) source.getChild(0); - if (singleTableNode.getType() == CMISParser.TABLE) - { - if (joinSupport == CMISJoinEnum.NO_JOIN_SUPPORT) - { - throw new UnsupportedOperationException("Joins are not supported"); - } - CommonTree tableSourceNode = (CommonTree) singleTableNode.getFirstChildWithType(CMISParser.SOURCE); - return buildSource(tableSourceNode, joinSupport, factory); - - } - if (singleTableNode.getType() != CMISParser.TABLE_REF) - { - throw new CMISQueryException("Expecting TABLE_REF token but found " + singleTableNode.getText()); - } - String tableName = singleTableNode.getChild(0).getText(); - String alias = ""; - if (singleTableNode.getChildCount() > 1) - { - alias = singleTableNode.getChild(1).getText(); - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeByQueryName(tableName); - if (typeDef == null) - { - throw new CMISQueryException("Type is unsupported in query: " + tableName); - } - if (typeDef.getTypeId().getScope() != CMISScope.POLICY) - { - if (!typeDef.isQueryable()) - { - throw new CMISQueryException("Type is not queryable " + tableName + " -> " + typeDef.getTypeId()); - } - } - return factory.createSelector(typeDef.getTypeId().getQName(), alias); - } - else - { - if (joinSupport == CMISJoinEnum.NO_JOIN_SUPPORT) - { - throw new UnsupportedOperationException("Joins are not supported"); - } - CommonTree singleTableNode = (CommonTree) source.getChild(0); - if (singleTableNode.getType() != CMISParser.TABLE_REF) - { - throw new CMISQueryException("Expecting TABLE_REF token but found " + singleTableNode.getText()); - } - String tableName = singleTableNode.getChild(0).getText(); - String alias = ""; - if (singleTableNode.getChildCount() == 2) - { - alias = singleTableNode.getChild(1).getText(); - } - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeByQueryName(tableName); - if (typeDef == null) - { - throw new CMISQueryException("Type is unsupported in query " + tableName); - } - if (typeDef.getTypeId().getScope() != CMISScope.POLICY) - { - if (!typeDef.isQueryable()) - { - throw new CMISQueryException("Type is not queryable " + tableName + " -> " + typeDef.getTypeId()); - } - } - - Source lhs = factory.createSelector(typeDef.getTypeId().getQName(), alias); - - List list = (List) (source.getChildren()); - for (CommonTree joinNode : list) - { - if (joinNode.getType() == CMISParser.JOIN) - { - CommonTree rhsSource = (CommonTree) joinNode.getFirstChildWithType(CMISParser.SOURCE); - Source rhs = buildSource(rhsSource, joinSupport, factory); - - JoinType joinType = JoinType.INNER; - CommonTree joinTypeNode = (CommonTree) joinNode.getFirstChildWithType(CMISParser.LEFT); - if (joinTypeNode != null) - { - joinType = JoinType.LEFT; - } - - if ((joinType == JoinType.LEFT) && (joinSupport == CMISJoinEnum.INNER_JOIN_SUPPORT)) - { - throw new UnsupportedOperationException("Outer joins are not supported"); - } - - Constraint joinCondition = null; - CommonTree joinConditionNode = (CommonTree) joinNode.getFirstChildWithType(CMISParser.ON); - if (joinConditionNode != null) - { - PropertyArgument arg1 = buildColumnReference(Equals.ARG_LHS, (CommonTree) joinConditionNode.getChild(0), factory, null, null); - if (!lhs.getSelectors().containsKey(arg1.getSelector()) && !rhs.getSelectors().containsKey(arg1.getSelector())) - { - throw new CMISQueryException("No table with alias " + arg1.getSelector()); - } - CommonTree functionNameNode = (CommonTree) joinConditionNode.getChild(1); - if (functionNameNode.getType() != CMISParser.EQUALS) - { - throw new CMISQueryException("Only Equi-join is supported " + functionNameNode.getText()); - } - Function function = factory.getFunction(Equals.NAME); - if (function == null) - { - throw new CMISQueryException("Unknown function: " + functionNameNode.getText()); - } - PropertyArgument arg2 = buildColumnReference(Equals.ARG_RHS, (CommonTree) joinConditionNode.getChild(2), factory, null, null); - if (!lhs.getSelectors().containsKey(arg2.getSelector()) && !rhs.getSelectors().containsKey(arg2.getSelector())) - { - throw new CMISQueryException("No table with alias " + arg2.getSelector()); - } - Map functionArguments = new LinkedHashMap(); - functionArguments.put(arg1.getName(), arg1); - functionArguments.put(arg2.getName(), arg2); - joinCondition = factory.createFunctionalConstraint(function, functionArguments); - } - - Source join = factory.createJoin(lhs, rhs, joinType, joinCondition); - lhs = join; - } - } - - return lhs; - - } - } - - public PropertyArgument buildColumnReference(String argumentName, CommonTree columnReferenceNode, QueryModelFactory factory, Map selectors, - Map columnMap) - { - String cmisPropertyName = columnReferenceNode.getChild(0).getText(); - String qualifier = ""; - if (columnReferenceNode.getChildCount() > 1) - { - qualifier = columnReferenceNode.getChild(1).getText(); - } - - if ((qualifier == "") && (columnMap != null)) - { - Column column = columnMap.get(cmisPropertyName); - if (column != null) - { - // check for function type - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - cmisPropertyName = arg.getPropertyName(); - qualifier = arg.getSelector(); - } - else - { - // TODO: should be able to return non property arguments - // The implementation should throw out what it can not support at build time. - throw new CMISQueryException("Complex column reference unsupported (only direct column references are currently supported) " + cmisPropertyName); - } - } - } - - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(cmisPropertyName); - if (propDef == null) - { - throw new CMISQueryException("Unknown column/property " + cmisPropertyName); - } - - if (selectors != null) - { - Selector selector = selectors.get(qualifier); - if (selector == null) - { - if ((qualifier.equals("")) && (selectors.size() == 1)) - { - selector = selectors.get(selectors.keySet().iterator().next()); - } - else - { - throw new CMISQueryException("No selector for " + qualifier); - } - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - - // Check column/property applies to selector/type - - if (!typeDef.getPropertyDefinitions().containsKey(propDef.getPropertyId().getId())) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + "." + cmisPropertyName); - } - } - - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - if (!propDef.isQueryable()) - { - throw new CMISQueryException("Column is not queryable " + qualifier + "." + cmisPropertyName); - } - } - return factory.createPropertyArgument(argumentName, propDef.isQueryable(), propDef.isOrderable(), qualifier, propDef.getPropertyId().getId()); - } - - private String unescape(String string, EscapeMode mode) - { - StringBuilder builder = new StringBuilder(string.length()); - - boolean lastWasEscape = false; - - for (int i = 0; i < string.length(); i++) - { - char c = string.charAt(i); - if (lastWasEscape) - { - - // Need to keep escaping for like as we have the same escaping - if (mode == EscapeMode.LIKE) - { - // Like does its own escaping - so pass through \ % and _ - if (c == '\'') - { - builder.append(c); - } - else if (c == '%') - { - builder.append('\\'); - builder.append(c); - } - else if (c == '_') - { - builder.append('\\'); - builder.append(c); - } - else if (c == '\\') - { - builder.append('\\'); - builder.append(c); - } - else - { - throw new UnsupportedOperationException("Unsupported escape pattern in <" + string + "> at position " + i); - } - } - else if (mode == EscapeMode.CONTAINS) - { - if (options.getQueryMode() == CMISQueryMode.CMS_STRICT) - { - if (c == '\'') - { - builder.append(c); - } - else if (c == '\\') - { - builder.append('\\'); - builder.append(c); - } - - else - { - throw new UnsupportedOperationException("Unsupported escape pattern in <" + string + "> at position " + i); - } - } - else - { - if (c == '\'') - { - builder.append(c); - } - else - { - builder.append(c); - } - } - } - else if (mode == EscapeMode.LITERAL) - { - if (c == '\'') - { - builder.append(c); - } - else if (c == '\\') - { - builder.append(c); - } - else - { - throw new UnsupportedOperationException("Unsupported escape pattern in <" + string + "> at position " + i); - - } - } - else - { - throw new UnsupportedOperationException("Unsupported escape pattern in <" + string + "> at position " + i); - - } - lastWasEscape = false; - } - else - { - if (c == '\\') - { - lastWasEscape = true; - } - else - { - builder.append(c); - } - } - } - if (lastWasEscape) - { - throw new FTSQueryException("Escape character at end of string " + string); - } - - return builder.toString(); - } -} diff --git a/source/java/org/alfresco/cmis/search/CMISQueryServiceImpl.java b/source/java/org/alfresco/cmis/search/CMISQueryServiceImpl.java deleted file mode 100644 index a984184402..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISQueryServiceImpl.java +++ /dev/null @@ -1,227 +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 . - */ -package org.alfresco.cmis.search; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISJoinEnum; -import org.alfresco.cmis.CMISQueryEnum; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISScope; -import org.alfresco.cmis.CMISServices; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.repo.search.impl.querymodel.QueryEngine; -import org.alfresco.repo.search.impl.querymodel.QueryEngineResults; -import org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.LimitBy; -import org.alfresco.service.cmr.search.ResultSet; - -/** - * @author andyh - */ -public class CMISQueryServiceImpl implements CMISQueryService -{ - private CMISServices cmisService; - - private CMISDictionaryService cmisDictionaryService; - - private QueryEngine queryEngine; - - private NodeService nodeService; - - private DictionaryService alfrescoDictionaryService; - - /** - * @param service - * the service to set - */ - public void setCMISService(CMISServices cmisService) - { - this.cmisService = cmisService; - } - - /** - * @param cmisDictionaryService - * the cmisDictionaryService to set - */ - public void setCMISDictionaryService(CMISDictionaryService cmisDictionaryService) - { - this.cmisDictionaryService = cmisDictionaryService; - } - - /** - * @param queryEngine - * the queryEngine to set - */ - public void setQueryEngine(QueryEngine queryEngine) - { - this.queryEngine = queryEngine; - } - - /** - * @param nodeService - * the nodeService to set - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - - - /** - * @param alfrescoDictionaryService - * the Alfresco Dictionary Service to set - */ - public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService) - { - this.alfrescoDictionaryService = alfrescoDictionaryService; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISQueryService#query(org.alfresco.cmis.search.CMISQueryOptions) - */ - public CMISResultSet query(CMISQueryOptions options) - { - CMISJoinEnum joinSupport = getJoinSupport(); - if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS) - { - joinSupport = CMISJoinEnum.INNER_JOIN_SUPPORT; - } - - // TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser - - CMISScope[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES; - CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext(); - functionContext.setCmisDictionaryService(cmisDictionaryService); - functionContext.setNodeService(nodeService); - functionContext.setValidScopes(validScopes); - - CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport); - Query query = parser.parse(queryEngine.getQueryModelFactory(), functionContext); - - QueryEngineResults results = queryEngine.executeQuery(query, options, functionContext); - Map wrapped = new HashMap(); - Map, ResultSet> map = results.getResults(); - for (Set group : map.keySet()) - { - ResultSet current = map.get(group); - for (String selector : group) - { - wrapped.put(selector, filterNotExistingNodes(current)); - } - } - LimitBy limitBy = null; - if ((null != results.getResults()) && !results.getResults().isEmpty() && (null != results.getResults().values()) && !results.getResults().values().isEmpty()) - { - limitBy = results.getResults().values().iterator().next().getResultSetMetaData().getLimitedBy(); - } - CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService); - return cmis; - } - - /* MNT-8804 filter ResultSet for nodes with corrupted indexes */ - private ResultSet filterNotExistingNodes(ResultSet resultSet) - { - if (resultSet instanceof PagingLuceneResultSet) - { - ResultSet wrapped = ((PagingLuceneResultSet)resultSet).getWrapped(); - - if (wrapped instanceof FilteringResultSet) - { - FilteringResultSet filteringResultSet = (FilteringResultSet)wrapped; - - for (int i = 0; i < filteringResultSet.length(); i++) - { - NodeRef nodeRef = filteringResultSet.getNodeRef(i); - /* filter node if it does not exist */ - if (!nodeService.exists(nodeRef)) - { - filteringResultSet.setIncluded(i, false); - } - } - } - } - - return resultSet; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISQueryService#query(java.lang.String) - */ - public CMISResultSet query(String query) - { - CMISQueryOptions options = new CMISQueryOptions(query, cmisService.getDefaultRootStoreRef()); - return query(options); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISQueryService#getPwcSearchable() - */ - public boolean getPwcSearchable() - { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISQueryService#getAllVersionsSearchable() - */ - public boolean getAllVersionsSearchable() - { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISQueryService#getQuerySupport() - */ - public CMISQueryEnum getQuerySupport() - { - return CMISQueryEnum.BOTH_COMBINED; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISQueryService#getJoinSupport() - */ - public CMISJoinEnum getJoinSupport() - { - return CMISJoinEnum.NO_JOIN_SUPPORT; - } -} diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetColumnImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetColumnImpl.java deleted file mode 100644 index 565fd0041a..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISResultSetColumnImpl.java +++ /dev/null @@ -1,89 +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 . - */ -package org.alfresco.cmis.search; - -import org.alfresco.cmis.CMISDataTypeEnum; -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISResultSetColumn; -import org.alfresco.service.namespace.QName; - -/** - * @author andyh - * - */ -public class CMISResultSetColumnImpl implements CMISResultSetColumn -{ - - private String name; - - private CMISPropertyDefinition propertyDefinition; - - private CMISDataTypeEnum dataType; - - private QName alfrescoPropertyQName; - - private QName alfrescoDataTypeQName; - - CMISResultSetColumnImpl(String name, CMISPropertyDefinition propertyDefinition, CMISDataTypeEnum dataType, QName alfrescoPropertyQName, QName alfrescoDataTypeQName) - { - this.name = name; - this.propertyDefinition = propertyDefinition; - this.dataType = dataType; - this.alfrescoPropertyQName = alfrescoPropertyQName; - this.alfrescoDataTypeQName = alfrescoDataTypeQName; - } - - - /* (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSetColumn#getName() - */ - public String getName() - { - return name; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSetColumn#getPropertyDefinition() - */ - public CMISPropertyDefinition getCMISPropertyDefinition() - { - return propertyDefinition; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSetColumn#getPropertyType() - */ - public CMISDataTypeEnum getCMISDataType() - { - return dataType; - } - - - public QName getDataType() - { - return alfrescoDataTypeQName; - } - - - public QName getPropertyType() - { - return alfrescoPropertyQName; - } - -} diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java deleted file mode 100644 index d6f725aeab..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISResultSetImpl.java +++ /dev/null @@ -1,357 +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 . - */ -package org.alfresco.cmis.search; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetRow; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.LimitBy; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; -import org.alfresco.util.Pair; - -/** - * @author andyh - */ -public class CMISResultSetImpl implements CMISResultSet, Serializable -{ - private static final long serialVersionUID = 2014688399588268994L; - - private Map wrapped; - - private LimitBy limitBy; - - CMISQueryOptions options; - - NodeService nodeService; - - Query query; - - CMISDictionaryService cmisDictionaryService; - - DictionaryService alfrescoDictionaryService; - - public CMISResultSetImpl(Map wrapped, CMISQueryOptions options, LimitBy limitBy, NodeService nodeService, Query query, - CMISDictionaryService cmisDictionaryService, DictionaryService alfrescoDictionaryService) - { - this.wrapped = wrapped; - this.options = options; - this.limitBy = limitBy; - this.nodeService = nodeService; - this.query = query; - this.cmisDictionaryService = cmisDictionaryService; - this.alfrescoDictionaryService = alfrescoDictionaryService; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSet#close() - */ - public void close() - { - // results sets can be used for more than one selector so we need to keep track of what we have closed - Set closed = new HashSet(); - for (ResultSet resultSet : wrapped.values()) - { - if (!closed.contains(resultSet)) - { - resultSet.close(); - closed.add(resultSet); - } - } - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSet#getMetaData() - */ - public CMISResultSetMetaData getMetaData() - { - return new CMISResultSetMetaDataImpl(options, query, limitBy, cmisDictionaryService, alfrescoDictionaryService); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSet#getRow(int) - */ - public CMISResultSetRow getRow(int i) - { - return new CMISResultSetRowImpl(this, i, getScores(i), nodeService, getNodeRefs(i), query, cmisDictionaryService); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSet#hasMore() - */ - public boolean hasMore() - { - for (ResultSet resultSet : wrapped.values()) - { - if (resultSet.hasMore()) - { - return true; - } - } - return false; - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSet#length() - */ - public int getLength() - { - for (ResultSet resultSet : wrapped.values()) - { - return resultSet.length(); - } - throw new IllegalStateException(); - } - - /* - * (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSet#start() - */ - public int getStart() - { - return options.getSkipCount(); - } - - /* - * (non-Javadoc) - * @see java.lang.Iterable#iterator() - */ - public Iterator iterator() - { - return new CMISResultSetRowIteratorImpl(this); - } - - private Map getNodeRefs(int i) - { - HashMap refs = new HashMap(); - for (String selector : wrapped.keySet()) - { - ResultSet rs = wrapped.get(selector); - refs.put(selector, rs.getNodeRef(i)); - } - return refs; - } - - private Map getScores(int i) - { - HashMap scores = new HashMap(); - for (String selector : wrapped.keySet()) - { - ResultSet rs = wrapped.get(selector); - scores.put(selector, Float.valueOf(rs.getScore(i))); - } - return scores; - } - - public ChildAssociationRef getChildAssocRef(int n) - { - NodeRef nodeRef = getNodeRef(n); - return nodeService.getPrimaryParent(nodeRef); - } - - public List getChildAssocRefs() - { - ArrayList cars = new ArrayList(length()); - for (ResultSetRow row : this) - { - cars.add(row.getChildAssocRef()); - } - return cars; - } - - public NodeRef getNodeRef(int n) - { - Map refs = getNodeRefs(n); - if (refs.size() == 1) - { - return refs.values().iterator().next(); - } - else if(allNodeRefsEqual(refs)) - { - return refs.values().iterator().next(); - } - else { - throw new IllegalStateException("Ambiguous selector"); - } - } - - private boolean allNodeRefsEqual(Map selected) - { - NodeRef last = null; - for (NodeRef current : selected.values()) - { - if (last == null) - { - last = current; - } - else - { - if (!last.equals(current)) - { - return false; - } - } - } - return true; - } - - public List getNodeRefs() - { - ArrayList nodeRefs = new ArrayList(length()); - for (ResultSetRow row : this) - { - nodeRefs.add(row.getNodeRef()); - } - return nodeRefs; - } - - public CMISResultSetMetaData getResultSetMetaData() - { - return getMetaData(); - } - - public float getScore(int n) - { - Map scores = getScores(n); - if (scores.size() == 1) - { - return scores.values().iterator().next(); - } - else if(allScoresEqual(scores)) - { - return scores.values().iterator().next(); - } - else - { - throw new IllegalStateException("Ambiguous selector"); - } - } - - private boolean allScoresEqual(Map scores) - { - Float last = null; - for (Float current : scores.values()) - { - if (last == null) - { - last = current; - } - else - { - if (!last.equals(current)) - { - return false; - } - } - } - return true; - } - - public int length() - { - return getLength(); - } - - /** - * Bulk fetch results in the cache - not supported here - * - * @param bulkFetch - */ - public boolean setBulkFetch(boolean bulkFetch) - { - return false; - } - - /** - * Do we bulk fetch - not supported here - * - * @return - true if we do - */ - public boolean getBulkFetch() - { - return false; - } - - /** - * Set the bulk fetch size - * - * @param bulkFetchSize - */ - public int setBulkFetchSize(int bulkFetchSize) - { - return 0; - } - - /** - * Get the bulk fetch size. - * - * @return the fetch size - */ - public int getBulkFetchSize() - { - return 0; - } - - @Override - public List> getFieldFacet(String field) - { - return Collections.>emptyList(); - } - - /* (non-Javadoc) - * @see org.alfresco.service.cmr.search.ResultSetSPI#getNumberFound() - */ - @Override - public long getNumberFound() - { - for (ResultSet resultSet : wrapped.values()) - { - return resultSet.getNumberFound(); - } - throw new IllegalStateException(); - } - - @Override - public Map getFacetQueries() - { - return Collections.emptyMap(); - } -} diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetMetaDataImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetMetaDataImpl.java deleted file mode 100644 index e2223d1dd0..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISResultSetMetaDataImpl.java +++ /dev/null @@ -1,200 +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 . - */ -package org.alfresco.cmis.search; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.alfresco.cmis.CMISDataTypeEnum; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISResultSetColumn; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetSelector; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.repo.search.impl.querymodel.Column; -import org.alfresco.repo.search.impl.querymodel.PropertyArgument; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.repo.search.impl.querymodel.Selector; -import org.alfresco.repo.search.impl.querymodel.impl.functions.PropertyAccessor; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; -import org.alfresco.service.cmr.search.LimitBy; -import org.alfresco.service.cmr.search.PermissionEvaluationMode; -import org.alfresco.service.cmr.search.ResultSetType; -import org.alfresco.service.cmr.search.SearchParameters; -import org.alfresco.service.namespace.QName; - -/** - * @author andyh - */ -public class CMISResultSetMetaDataImpl implements CMISResultSetMetaData -{ - private CMISQueryOptions options; - private SearchParameters searchParams; - private LimitBy limitBy; - - private Map columnMetaData; - - private Map selectorMetaData; - - public CMISResultSetMetaDataImpl(CMISQueryOptions options, Query query, LimitBy limitBy, CMISDictionaryService cmisDictionaryService, - DictionaryService alfrescoDictionaryService) - { - this.options = options; - this.searchParams = new SearchParameters(options); - this.limitBy = limitBy; - Map selectors = query.getSource().getSelectors(); - selectorMetaData = new LinkedHashMap(); - for(Selector selector : selectors.values()) - { - CMISTypeDefinition type = cmisDictionaryService.findTypeForClass(selector.getType()); - CMISResultSetSelector smd = new CMISResultSetSelectorImpl(selector.getAlias(), type); - selectorMetaData.put(smd.getName(), smd); - } - - columnMetaData = new LinkedHashMap(); - for (Column column : query.getColumns()) - { - CMISPropertyDefinition propertyDefinition = null; - CMISDataTypeEnum type = null; - QName alfrescoPropertyQName = null; - QName alfrescoDataTypeQName = null; - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - String propertyName = arg.getPropertyName(); - alfrescoPropertyQName = QName.createQName(propertyName); - PropertyDefinition alfPropDef = alfrescoDictionaryService.getProperty(alfrescoPropertyQName); - if(alfPropDef == null) - { - alfrescoPropertyQName = null; - } - else - { - alfrescoDataTypeQName = alfPropDef.getDataType().getName(); - } - propertyDefinition = cmisDictionaryService.findProperty(propertyName, null); - type = propertyDefinition.getDataType(); - } - if (type == null) - { - type = cmisDictionaryService.findDataType(column.getFunction().getReturnType()); - } - if(alfrescoDataTypeQName == null) - { - alfrescoDataTypeQName = type.getDefaultDataType(); - } - CMISResultSetColumn cmd = new CMISResultSetColumnImpl(column.getAlias(), propertyDefinition, type, alfrescoPropertyQName, alfrescoDataTypeQName); - columnMetaData.put(cmd.getName(), cmd); - } - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getColumnNames() - */ - public String[] getColumnNames() - { - return columnMetaData.keySet().toArray(new String[0]); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getColumns() - */ - public CMISResultSetColumn[] getColumns() - { - return columnMetaData.values().toArray(new CMISResultSetColumn[0]); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getCoumn(java.lang.String) - */ - public CMISResultSetColumn getColumn(String name) - { - return columnMetaData.get(name); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getQueryOptions() - */ - public CMISQueryOptions getQueryOptions() - { - return options; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getSelector(java.lang.String) - */ - public CMISResultSetSelector getSelector(String name) - { - return selectorMetaData.get(name); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getSelectorNames() - */ - public String[] getSelectorNames() - { - return selectorMetaData.keySet().toArray(new String[0]); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.cmis.search.CMISResultSetMetaData#getSelectors() - */ - public CMISResultSetSelector[] getSelectors() - { - return selectorMetaData.values().toArray(new CMISResultSetSelector[0]); - } - - public LimitBy getLimitedBy() - { - return limitBy; - } - - public PermissionEvaluationMode getPermissionEvaluationMode() - { - throw new UnsupportedOperationException(); - } - - public ResultSetType getResultSetType() - { - return ResultSetType.COLUMN_AND_NODE_REF; - } - - public SearchParameters getSearchParameters() - { - return searchParams; - } - -} diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java deleted file mode 100644 index fc428a8f5c..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISResultSetRowImpl.java +++ /dev/null @@ -1,252 +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 . - */ -package org.alfresco.cmis.search; - -import java.io.Serializable; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetRow; -import org.alfresco.repo.search.impl.querymodel.Column; -import org.alfresco.repo.search.impl.querymodel.PropertyArgument; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.repo.search.impl.querymodel.impl.functions.PropertyAccessor; -import org.alfresco.repo.search.results.ResultSetSPIWrapper; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.namespace.QName; - -/** - * @author andyh - */ -public class CMISResultSetRowImpl implements CMISResultSetRow -{ - /** - * The containing result set - */ - private CMISResultSet resultSet; - - /** - * The current position in the containing result set - */ - private int index; - - private Map scores; - - private NodeService nodeService; - - private Map nodeRefs; - - private Query query; - - private CMISDictionaryService cmisDictionaryService; - - public CMISResultSetRowImpl( - CMISResultSet resultSet, int index, Map scores, - NodeService nodeService, Map nodeRefs, Query query, - CMISDictionaryService cmisDictionaryService) - { - this.resultSet = resultSet; - this.index = index; - this.scores = scores; - this.nodeService = nodeService; - this.nodeRefs = nodeRefs; - this.query = query; - this.cmisDictionaryService = cmisDictionaryService; - } - - @Override - public int getIndex() - { - return index; - } - - @Override - public ResultSet getResultSet() - { - return new ResultSetSPIWrapper(resultSet); - } - - @Override - public float getScore() - { - float count = 0; - float overall = 0; - for (Float score : scores.values()) - { - overall = (overall * (count / (count + 1.0f))) + (score / (count + 1.0f)); - } - return overall; - } - - @Override - public float getScore(String selectorName) - { - return scores.get(selectorName); - } - - @Override - public Map getScores() - { - return scores; - } - - @Override - public NodeRef getNodeRef(String selectorName) - { - return nodeRefs.get(selectorName); - } - - @Override - public Map getNodeRefs() - { - return nodeRefs; - } - - @Override - public Serializable getValue(String columnName) - { - CmisFunctionEvaluationContext context = new CmisFunctionEvaluationContext(); - context.setCmisDictionaryService(cmisDictionaryService); - context.setNodeRefs(nodeRefs); - context.setNodeService(nodeService); - context.setScores(scores); - context.setScore(getScore()); - for (Column column : query.getColumns()) - { - if (column.getAlias().equals(columnName)) - { - return column.getFunction().getValue(column.getFunctionArguments(), context); - } - // Special case for one selector - ignore any table aliases - // also allows look up direct and not by alias - // Perhaps we should add the duplicates instead - // TODO: check SQL 92 for single alias table behaviour for selectors - if (nodeRefs.size() == 1) - { - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - String propertyName = arg.getPropertyName(); - if (propertyName.equals(columnName)) - { - return column.getFunction().getValue(column.getFunctionArguments(), context); - } - StringBuilder builder = new StringBuilder(); - builder.append(arg.getSelector()).append(".").append(propertyName); - propertyName = builder.toString(); - if (propertyName.equals(columnName)) - { - return column.getFunction().getValue(column.getFunctionArguments(), context); - } - } - } - else - { - if (column.getFunction().getName().equals(PropertyAccessor.NAME)) - { - PropertyArgument arg = (PropertyArgument) column.getFunctionArguments().get(PropertyAccessor.ARG_PROPERTY); - StringBuilder builder = new StringBuilder(); - builder.append(arg.getSelector()).append(".").append(arg.getPropertyName()); - String propertyName = builder.toString(); - if (propertyName.equals(columnName)) - { - return column.getFunction().getValue(column.getFunctionArguments(), context); - } - } - } - } - return null; - } - - @Override - public Map getValues() - { - LinkedHashMap answer = new LinkedHashMap(); - for (String column : resultSet.getMetaData().getColumnNames()) - { - answer.put(column, getValue(column)); - } - return answer; - } - - @Override - public CMISResultSet getCMISResultSet() - { - return resultSet; - } - - @Override - public ChildAssociationRef getChildAssocRef() - { - NodeRef nodeRef = getNodeRef(); - return nodeService.getPrimaryParent(nodeRef); - } - - @Override - public NodeRef getNodeRef() - { - if (nodeRefs.size() == 1) - { - return nodeRefs.values().iterator().next(); - } - else if(allNodeRefsEqual(nodeRefs)) - { - return nodeRefs.values().iterator().next(); - } - throw new UnsupportedOperationException("Ambiguous selector"); - } - - private boolean allNodeRefsEqual(Map selected) - { - NodeRef last = null; - for(NodeRef current : selected.values()) - { - if(last == null) - { - last = current; - } - else - { - if(!last.equals(current)) - { - return false; - } - } - } - return true; - } - - @Override - public QName getQName() - { - return getChildAssocRef().getQName(); - } - - @Override - public Serializable getValue(QName qname) - { - throw new UnsupportedOperationException(); - } -} diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetRowIteratorImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetRowIteratorImpl.java deleted file mode 100644 index 35f58ed784..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISResultSetRowIteratorImpl.java +++ /dev/null @@ -1,132 +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 . - */ -package org.alfresco.cmis.search; - -import java.util.ListIterator; - -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISResultSetRow; - -/** - * @author andyh - */ -public class CMISResultSetRowIteratorImpl implements ListIterator -{ - /** - * The result set - */ - private CMISResultSet resultSet; - - /** - * The current position - */ - private int position = -1; - - /** - * The maximum position - */ - private int max; - - /** - * Create an iterator over the result set. Follows stadard ListIterator conventions - * - * @param resultSet - */ - public CMISResultSetRowIteratorImpl(CMISResultSet resultSet) - { - this.resultSet = resultSet; - this.max = resultSet.getLength(); - } - - public CMISResultSet getResultSet() - { - return resultSet; - } - - /* - * ListIterator implementation - */ - public boolean hasNext() - { - return position < (max - 1); - } - - public boolean allowsReverse() - { - return true; - } - - public boolean hasPrevious() - { - return position > 0; - } - - public CMISResultSetRow next() - { - return resultSet.getRow(moveToNextPosition()); - } - - protected int moveToNextPosition() - { - return ++position; - } - - public CMISResultSetRow previous() - { - return resultSet.getRow(moveToPreviousPosition()); - } - - protected int moveToPreviousPosition() - { - return --position; - } - - public int nextIndex() - { - return position + 1; - } - - public int previousIndex() - { - return position - 1; - } - - /* - * Mutation is not supported - */ - - public void remove() - { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); - } - - public void set(CMISResultSetRow o) - { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); - } - - public void add(CMISResultSetRow o) - { - // TODO Auto-generated method stub - throw new UnsupportedOperationException(); - } - -} diff --git a/source/java/org/alfresco/cmis/search/CMISResultSetSelectorImpl.java b/source/java/org/alfresco/cmis/search/CMISResultSetSelectorImpl.java deleted file mode 100644 index ae5e32fe97..0000000000 --- a/source/java/org/alfresco/cmis/search/CMISResultSetSelectorImpl.java +++ /dev/null @@ -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 . - */ -package org.alfresco.cmis.search; - -import org.alfresco.cmis.CMISResultSetSelector; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.service.namespace.QName; - -/** - * @author andyh - * - */ -public class CMISResultSetSelectorImpl implements CMISResultSetSelector -{ - private String name; - - private CMISTypeDefinition typeDefinition; - - public CMISResultSetSelectorImpl(String name, CMISTypeDefinition typeDefinition) - { - this.name = name; - this.typeDefinition = typeDefinition; - } - - - /* (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSetSelector#getName() - */ - public String getName() - { - return name; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.search.CMISResultSetSelector#getTypeDefinition() - */ - public CMISTypeDefinition getTypeDefinition() - { - return typeDefinition; - } - - - public QName getType() - { - return typeDefinition.getTypeId().getQName(); - } - -} diff --git a/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java b/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java deleted file mode 100644 index ca0e786bac..0000000000 --- a/source/java/org/alfresco/cmis/search/CmisFunctionEvaluationContext.java +++ /dev/null @@ -1,494 +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 . - */ -package org.alfresco.cmis.search; - -import java.io.Serializable; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; - -import org.alfresco.cmis.CMISCardinalityEnum; -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISQueryException; -import org.alfresco.cmis.CMISScope; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.repo.search.adaptor.lucene.LuceneFunction; -import org.alfresco.repo.search.adaptor.lucene.LuceneQueryParserAdaptor; -import org.alfresco.repo.search.adaptor.lucene.QueryConstants; -import org.alfresco.repo.search.impl.querymodel.FunctionArgument; -import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext; -import org.alfresco.repo.search.impl.querymodel.PredicateMode; -import org.alfresco.repo.search.impl.querymodel.QueryModelException; -import org.alfresco.repo.search.impl.querymodel.Selector; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Lower; -import org.alfresco.repo.search.impl.querymodel.impl.functions.Upper; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.QName; -import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException; - -/** - * @author andyh - */ -@SuppressWarnings("deprecation") -public class CmisFunctionEvaluationContext implements FunctionEvaluationContext -{ - private static HashSet EXPOSED_FIELDS = new HashSet(); - - public static CMISScope[] STRICT_SCOPES = new CMISScope[] { CMISScope.DOCUMENT, CMISScope.FOLDER }; - - public static CMISScope[] ALFRESCO_SCOPES = new CMISScope[] { CMISScope.DOCUMENT, CMISScope.FOLDER, CMISScope.POLICY }; - - private Map nodeRefs; - - private Map scores; - - private NodeService nodeService; - - private CMISDictionaryService cmisDictionaryService; - - private CMISScope[] validScopes; - - private Float score; - - static - { - EXPOSED_FIELDS.add(QueryConstants.FIELD_PATH); - EXPOSED_FIELDS.add(QueryConstants.FIELD_TEXT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ID); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ISROOT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ISNODE); - EXPOSED_FIELDS.add(QueryConstants.FIELD_TX); - EXPOSED_FIELDS.add(QueryConstants.FIELD_PARENT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_PRIMARYPARENT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_QNAME); - EXPOSED_FIELDS.add(QueryConstants.FIELD_CLASS); - EXPOSED_FIELDS.add(QueryConstants.FIELD_TYPE); - EXPOSED_FIELDS.add(QueryConstants.FIELD_EXACTTYPE); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ASPECT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_EXACTASPECT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ALL); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ISUNSET); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ISNULL); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ISNOTNULL); - EXPOSED_FIELDS.add(QueryConstants.FIELD_FTSSTATUS); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ASSOCTYPEQNAME); - EXPOSED_FIELDS.add(QueryConstants.FIELD_PRIMARYASSOCTYPEQNAME); - EXPOSED_FIELDS.add(QueryConstants.FIELD_DBID); - EXPOSED_FIELDS.add(QueryConstants.FIELD_TAG); - EXPOSED_FIELDS.add(QueryConstants.FIELD_TENANT); - EXPOSED_FIELDS.add(QueryConstants.FIELD_ANCESTOR); - - - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.ANY.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.ASSOC_REF.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.BOOLEAN.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.CATEGORY.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.CHILD_ASSOC_REF.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.CONTENT.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.DATE.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.DATETIME.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.DOUBLE.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.FLOAT.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.INT.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.LOCALE.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.LONG.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.MLTEXT.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.NODE_REF.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.PATH.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.PERIOD.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.QNAME.getLocalName()); - EXPOSED_FIELDS.add("d:"+DataTypeDefinition.TEXT.getLocalName()); - } - - /** - * @param nodeRefs - * the nodeRefs to set - */ - public void setNodeRefs(Map nodeRefs) - { - this.nodeRefs = nodeRefs; - } - - /** - * @param scores - * the scores to set - */ - public void setScores(Map scores) - { - this.scores = scores; - } - - /** - * @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; - } - - /** - * @param validScopes - * the valid scopes to set - */ - public void setValidScopes(CMISScope[] validScopes) - { - this.validScopes = validScopes; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getNodeRefs() - */ - public Map getNodeRefs() - { - return nodeRefs; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getNodeService() - */ - public NodeService getNodeService() - { - return nodeService; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getProperty(org.alfresco.service.cmr.repository.NodeRef, - * org.alfresco.service.namespace.QName) - */ - public Serializable getProperty(NodeRef nodeRef, String propertyName) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyAccessor().getValue(nodeRef); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getScores() - */ - public Map getScores() - { - return scores; - } - - /** - * @return the score - */ - public Float getScore() - { - return score; - } - - /** - * @param score - * the score to set - */ - public void setScore(Float score) - { - this.score = score; - } - - public Q buildLuceneEquality(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneEquality(lqpa, value, mode, luceneFunction); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneExists(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.lang.Boolean) - */ - public Q buildLuceneExists(LuceneQueryParserAdaptor lqpa, String propertyName, Boolean not) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneExists(lqpa, not); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneGreaterThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.io.Serializable, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Q buildLuceneGreaterThan(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThan(lqpa, value, mode, luceneFunction); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneGreaterThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.io.Serializable, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThanOrEquals(lqpa, value, mode, luceneFunction); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneIn(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.util.Collection, java.lang.Boolean, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Q buildLuceneIn(LuceneQueryParserAdaptor lqpa, String propertyName, Collection values, Boolean not, PredicateMode mode) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneIn(lqpa, values, not, mode); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneInequality(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.io.Serializable, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Q buildLuceneInequality(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneInequality(lqpa, value, mode, luceneFunction); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneLessThan(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.io.Serializable, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Q buildLuceneLessThan(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThan(lqpa, value, mode, luceneFunction); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneLessThanOrEquals(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.io.Serializable, - * org.alfresco.repo.search.impl.querymodel.PredicateMode) - */ - public Q buildLuceneLessThanOrEquals(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThanOrEquals(lqpa, value, mode, luceneFunction); - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#buildLuceneLike(org.alfresco.repo.search.impl.lucene.LuceneQueryParser, - * org.alfresco.service.namespace.QName, java.io.Serializable, java.lang.Boolean) - */ - public Q buildLuceneLike(LuceneQueryParserAdaptor lqpa, String propertyName, Serializable value, Boolean not) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().buildLuceneLike(lqpa, value, not); - } - - /* (non-Javadoc) - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getLuceneSortField(org.alfresco.service.namespace.QName) - */ - public String getLuceneSortField(LuceneQueryParserAdaptor lqpa, String propertyName) throws E - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - return propertyDef.getPropertyLuceneBuilder().getLuceneSortField(lqpa); - } - - - public boolean isObjectId(String propertyName) - { - return CMISDictionaryModel.PROP_OBJECT_ID.equalsIgnoreCase(propertyName); - } - - public boolean isOrderable(String fieldName) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(fieldName, null); - if(propertyDef == null) - { - return false; - } - else - { - return propertyDef.isOrderable(); - } - } - - public boolean isQueryable(String fieldName) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(fieldName, null); - if(propertyDef == null) - { - return true; - } - else - { - return propertyDef.isQueryable(); - } - } - - public String getLuceneFieldName(String propertyName) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - if(propertyDef != null) - { - return propertyDef.getPropertyLuceneBuilder().getLuceneFieldName(); - } - else - { - // TODO: restrict to supported "special" fields - return propertyName; - } - } - - public LuceneFunction getLuceneFunction(FunctionArgument functionArgument) - { - if (functionArgument == null) - { - return LuceneFunction.FIELD; - } - else - { - String functionName = functionArgument.getFunction().getName(); - if (functionName.equals(Upper.NAME)) - { - return LuceneFunction.UPPER; - } - else if (functionName.equals(Lower.NAME)) - { - return LuceneFunction.LOWER; - } - else - { - throw new QueryModelException("Unsupported function: " + functionName); - } - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#checkFieldApplies(org.alfresco.service.namespace.QName, java.lang.String) - */ - public void checkFieldApplies(Selector selector, String propertyName) - { - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(propertyName); - if (propDef == null) - { - if (EXPOSED_FIELDS.contains(propertyName)) - { - return; - } - else - { - throw new CMISQueryException("Unknown column/property " + propertyName); - } - } - - CMISTypeDefinition typeDef = cmisDictionaryService.findTypeForClass(selector.getType(), validScopes); - if (typeDef == null) - { - throw new CMISQueryException("Type unsupported in CMIS queries: " + selector.getAlias()); - } - - // Check column/property applies to selector/type - - if (!typeDef.getPropertyDefinitions().containsKey(propDef.getPropertyId().getId())) - { - throw new CMISQueryException("Invalid column for " + typeDef.getQueryName() + "." + propertyName); - } - - } - - /* (non-Javadoc) - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#isMultiValued(java.lang.String) - */ - public boolean isMultiValued(String propertyName) - { - CMISPropertyDefinition propDef = cmisDictionaryService.findPropertyByQueryName(propertyName); - if (propDef == null) - { - throw new CMISQueryException("Unknown column/property " + propertyName); - } - return propDef.getCardinality() == CMISCardinalityEnum.MULTI_VALUED; - } - - /* (non-Javadoc) - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getAlfrescoPropertyName(java.lang.String) - */ - @Override - public String getAlfrescoPropertyName(String propertyName) - { - CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyName, null); - if(propertyDef != null) - { - QName mapped = propertyDef.getPropertyAccessor().getMappedProperty(); - if(mapped == null) - { - return propertyName; - } - else - { - return mapped.toString(); - } - } - else - { - throw new CmisInvalidArgumentException("Unknown column/property " + propertyName); - } - } - - /* (non-Javadoc) - * @see org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext#getAlfrescoTypeName(java.lang.String) - */ - @Override - public String getAlfrescoTypeName(String typeName) - { - throw new CMISQueryException("Unsupported"); - } - -} diff --git a/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java b/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java index 1a3969321d..448d90867d 100644 --- a/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java +++ b/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java @@ -39,7 +39,6 @@ import javax.servlet.http.HttpServletRequest; import net.sf.acegisecurity.Authentication; -import org.alfresco.cmis.CMISInvalidArgumentException; import org.alfresco.model.ContentModel; import org.alfresco.opencmis.dictionary.CMISNodeInfo; import org.alfresco.opencmis.dictionary.CMISObjectVariant; @@ -1523,7 +1522,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr if (!found) { throw new IllegalArgumentException( - new CMISInvalidArgumentException( + new CmisInvalidArgumentException( "Document is not a child of the source folder that was specified!")); } } diff --git a/source/java/org/alfresco/opencmis/CMISConnector.java b/source/java/org/alfresco/opencmis/CMISConnector.java index 637e1b5223..4e39d6c914 100644 --- a/source/java/org/alfresco/opencmis/CMISConnector.java +++ b/source/java/org/alfresco/opencmis/CMISConnector.java @@ -47,7 +47,6 @@ import java.util.TreeSet; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; -import org.alfresco.cmis.CMISDictionaryModel; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.events.types.ContentEvent; import org.alfresco.events.types.ContentEventImpl; @@ -860,7 +859,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen PropertyDefinitionWrapper propDef = getOpenCMISDictionaryService().findPropertyByQueryName(cmisPropertyName); if (propDef != null) { - if (propDef.getPropertyId().equals(CMISDictionaryModel.PROP_BASE_TYPE_ID)) + if (propDef.getPropertyId().equals(PropertyIds.BASE_TYPE_ID)) { // special-case (see also ALF-13968) - for getChildren, using "cmis:baseTypeId" allows sorting of folders first and vice-versa (cmis:folder <-> cmis:document) sortPropName = GetChildrenCannedQuery.SORT_QNAME_NODE_IS_FOLDER; diff --git a/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java b/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java index 4e586dd415..240ecd6b6b 100644 --- a/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java +++ b/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java @@ -20,10 +20,10 @@ package org.alfresco.opencmis.mapping; import java.io.Serializable; -import org.alfresco.cmis.CMISDictionaryModel; import org.alfresco.opencmis.CMISConnector; import org.alfresco.opencmis.dictionary.CMISNodeInfo; import org.alfresco.service.ServiceRegistry; +import org.apache.chemistry.opencmis.commons.PropertyIds; /** * Accessor for the CMIS Checkin Comment @@ -39,7 +39,7 @@ public class CheckinCommentProperty extends AbstractProperty */ public CheckinCommentProperty(ServiceRegistry serviceRegistry, CMISConnector connector) { - super(serviceRegistry, connector, CMISDictionaryModel.PROP_CHECKIN_COMMENT); + super(serviceRegistry, connector, PropertyIds.CHECKIN_COMMENT); } public Serializable getValueInternal(CMISNodeInfo nodeInfo) diff --git a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java index 974d7186c1..3d347ef737 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneSearcherImpl.java @@ -21,7 +21,6 @@ package org.alfresco.repo.search.impl.lucene; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -31,42 +30,18 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetRow; -import org.springframework.extensions.surf.util.I18NUtil; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.dictionary.IndexTokenisationMode; import org.alfresco.repo.search.CannedQueryDef; -import org.alfresco.repo.search.EmptyResultSet; import org.alfresco.repo.search.MLAnalysisMode; import org.alfresco.repo.search.QueryRegisterComponent; import org.alfresco.repo.search.SearcherException; import org.alfresco.repo.search.impl.NodeSearcher; -import org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser; -import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser; -import org.alfresco.repo.search.impl.parsers.AlfrescoFunctionEvaluationContext; -import org.alfresco.repo.search.impl.parsers.FTSQueryParser; -import org.alfresco.repo.search.impl.querymodel.Constraint; -import org.alfresco.repo.search.impl.querymodel.QueryEngine; -import org.alfresco.repo.search.impl.querymodel.QueryEngineResults; -import org.alfresco.repo.search.impl.querymodel.QueryModelFactory; -import org.alfresco.repo.search.impl.querymodel.QueryOptions; -import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; -import org.alfresco.repo.search.results.ResultSetSPIWrapper; -import org.alfresco.repo.search.results.SortedResultSet; import org.alfresco.repo.tenant.TenantService; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.Path; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.XPathException; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.cmr.search.LimitBy; import org.alfresco.service.cmr.search.QueryParameter; import org.alfresco.service.cmr.search.QueryParameterDefinition; import org.alfresco.service.cmr.search.ResultSet; @@ -80,18 +55,9 @@ import org.alfresco.util.SearchLanguageConversion; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexReader.FieldOption; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermEnum; -import org.apache.lucene.index.IndexReader.FieldOption; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.queryParser.QueryParser.Operator; -import org.apache.lucene.search.Hits; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.Searcher; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.SortField; -import org.jaxen.saxpath.SAXPathException; -import org.jaxen.saxpath.base.XPathReader; /** * The Lucene implementation of Searcher At the moment we support only lucene based queries. TODO: Support for other diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneAlfrescoSqlQueryLanguage.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneAlfrescoSqlQueryLanguage.java index 691886f033..16749c9482 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneAlfrescoSqlQueryLanguage.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneAlfrescoSqlQueryLanguage.java @@ -18,16 +18,12 @@ */ package org.alfresco.repo.search.impl.lucene; -import java.util.List; - -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetRow; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; +import org.alfresco.opencmis.search.CMISQueryOptions; +import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode; +import org.alfresco.opencmis.search.CMISQueryService; +import org.alfresco.opencmis.search.CMISResultSetMetaData; +import org.alfresco.opencmis.search.CMISResultSetRow; import org.alfresco.repo.search.results.ResultSetSPIWrapper; -import org.alfresco.service.cmr.search.LimitBy; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchService; diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneCmisStrictSqlQueryLanguage.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneCmisStrictSqlQueryLanguage.java index 7568b616e7..9f61505578 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneCmisStrictSqlQueryLanguage.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneCmisStrictSqlQueryLanguage.java @@ -18,16 +18,12 @@ */ package org.alfresco.repo.search.impl.lucene; -import java.util.List; - -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetRow; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; +import org.alfresco.opencmis.search.CMISQueryOptions; +import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode; +import org.alfresco.opencmis.search.CMISQueryService; +import org.alfresco.opencmis.search.CMISResultSetMetaData; +import org.alfresco.opencmis.search.CMISResultSetRow; import org.alfresco.repo.search.results.ResultSetSPIWrapper; -import org.alfresco.service.cmr.search.LimitBy; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchService; diff --git a/source/java/org/alfresco/repo/search/impl/lucene/PagingLuceneResultSet.java b/source/java/org/alfresco/repo/search/impl/lucene/PagingLuceneResultSet.java index f5646e89b1..6a3beba7c1 100644 --- a/source/java/org/alfresco/repo/search/impl/lucene/PagingLuceneResultSet.java +++ b/source/java/org/alfresco/repo/search/impl/lucene/PagingLuceneResultSet.java @@ -58,7 +58,7 @@ public class PagingLuceneResultSet implements ResultSet, Serializable /* * (non-Javadoc) * - * @see org.alfresco.cmis.search.CMISResultSet#close() + * @see org.alfresco.opencmis.search.CMISResultSet#close() */ public void close() { @@ -68,7 +68,7 @@ public class PagingLuceneResultSet implements ResultSet, Serializable /* * (non-Javadoc) * - * @see org.alfresco.cmis.search.CMISResultSet#getRow(int) + * @see org.alfresco.opencmis.search.CMISResultSet#getRow(int) */ public ResultSetRow getRow(int i) { @@ -78,7 +78,7 @@ public class PagingLuceneResultSet implements ResultSet, Serializable /* * (non-Javadoc) * - * @see org.alfresco.cmis.search.CMISResultSet#hasMore() + * @see org.alfresco.opencmis.search.CMISResultSet#hasMore() */ public boolean hasMore() { @@ -104,7 +104,7 @@ public class PagingLuceneResultSet implements ResultSet, Serializable /* * (non-Javadoc) * - * @see org.alfresco.cmis.search.CMISResultSet#length() + * @see org.alfresco.opencmis.search.CMISResultSet#length() */ public int getLength() { @@ -125,7 +125,7 @@ public class PagingLuceneResultSet implements ResultSet, Serializable /* * (non-Javadoc) * - * @see org.alfresco.cmis.search.CMISResultSet#start() + * @see org.alfresco.opencmis.search.CMISResultSet#start() */ public int getStart() { diff --git a/source/java/org/alfresco/repo/search/impl/noindex/NoIndexCMISQueryServiceImpl.java b/source/java/org/alfresco/repo/search/impl/noindex/NoIndexCMISQueryServiceImpl.java deleted file mode 100644 index bbd249e0bc..0000000000 --- a/source/java/org/alfresco/repo/search/impl/noindex/NoIndexCMISQueryServiceImpl.java +++ /dev/null @@ -1,168 +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 . - */ -package org.alfresco.repo.search.impl.noindex; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISJoinEnum; -import org.alfresco.cmis.CMISQueryEnum; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISScope; -import org.alfresco.cmis.CMISServices; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.cmis.search.CMISQueryParser; -import org.alfresco.cmis.search.CMISResultSetImpl; -import org.alfresco.cmis.search.CmisFunctionEvaluationContext; -import org.alfresco.repo.search.EmptyResultSet; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.repo.search.impl.querymodel.QueryEngineResults; -import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryModelFactory; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.LimitBy; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchParameters; - -/** - * @author Andy - * - */ -public class NoIndexCMISQueryServiceImpl implements CMISQueryService -{ - private CMISServices cmisService; - - private CMISDictionaryService cmisDictionaryService; - - private NodeService nodeService; - - private DictionaryService alfrescoDictionaryService; - - public void setCmisService(CMISServices cmisService) - { - this.cmisService = cmisService; - } - - public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService) - { - this.cmisDictionaryService = cmisDictionaryService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService) - { - this.alfrescoDictionaryService = alfrescoDictionaryService; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#query(org.alfresco.cmis.CMISQueryOptions) - */ - @Override - public CMISResultSet query(CMISQueryOptions options) - { - ResultSet rs = new EmptyResultSet(); - - CMISJoinEnum joinSupport = getJoinSupport(); - if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS) - { - joinSupport = CMISJoinEnum.INNER_JOIN_SUPPORT; - } - - // TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser - - CMISScope[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES; - CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext(); - functionContext.setCmisDictionaryService(cmisDictionaryService); - functionContext.setNodeService(nodeService); - functionContext.setValidScopes(validScopes); - - CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport); - Query query = parser.parse(new LuceneQueryModelFactory(), functionContext); - - Map wrapped = new HashMap(); - for (Set group : query.getSource().getSelectorGroups(functionContext)) - { - for (String selector : group) - { - wrapped.put(selector, rs); - } - } - LimitBy limitBy = null; - limitBy = rs.getResultSetMetaData().getLimitedBy(); - - CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService); - return cmis; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#query(java.lang.String) - */ - @Override - public CMISResultSet query(String query) - { - CMISQueryOptions options = new CMISQueryOptions(query, cmisService.getDefaultRootStoreRef()); - return query(options); - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getQuerySupport() - */ - @Override - public CMISQueryEnum getQuerySupport() - { - return CMISQueryEnum.BOTH_COMBINED; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getJoinSupport() - */ - @Override - public CMISJoinEnum getJoinSupport() - { - return CMISJoinEnum.NO_JOIN_SUPPORT; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getPwcSearchable() - */ - @Override - public boolean getPwcSearchable() - { - return true; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getAllVersionsSearchable() - */ - @Override - public boolean getAllVersionsSearchable() - { - return false; - } - - -} diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryServiceImpl.java b/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryServiceImpl.java deleted file mode 100644 index 30f11611bf..0000000000 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrCMISQueryServiceImpl.java +++ /dev/null @@ -1,173 +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 . - */ -package org.alfresco.repo.search.impl.solr; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISJoinEnum; -import org.alfresco.cmis.CMISQueryEnum; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISScope; -import org.alfresco.cmis.CMISServices; -import org.alfresco.cmis.search.CMISQueryParser; -import org.alfresco.cmis.search.CMISResultSetImpl; -import org.alfresco.cmis.search.CmisFunctionEvaluationContext; -import org.alfresco.repo.search.impl.lucene.LuceneQueryLanguageSPI; -import org.alfresco.repo.search.impl.querymodel.Query; -import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryModelFactory; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.LimitBy; -import org.alfresco.service.cmr.search.ResultSet; - -/** - * @author Andy - * - */ -public class SolrCMISQueryServiceImpl implements CMISQueryService -{ - private CMISServices cmisService; - - private LuceneQueryLanguageSPI solrQueryLanguage; - - private CMISDictionaryService cmisDictionaryService; - - private NodeService nodeService; - - private DictionaryService alfrescoDictionaryService; - - public void setCmisService(CMISServices cmisService) - { - this.cmisService = cmisService; - } - - public void setSolrQueryLanguage(LuceneQueryLanguageSPI solrQueryLanguage) - { - this.solrQueryLanguage = solrQueryLanguage; - } - - public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService) - { - this.cmisDictionaryService = cmisDictionaryService; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService) - { - this.alfrescoDictionaryService = alfrescoDictionaryService; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#query(org.alfresco.cmis.CMISQueryOptions) - */ - @Override - public CMISResultSet query(CMISQueryOptions options) - { - ResultSet rs = solrQueryLanguage.executeQuery(options.getAsSearchParmeters(), null); - - CMISJoinEnum joinSupport = getJoinSupport(); - if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS) - { - joinSupport = CMISJoinEnum.INNER_JOIN_SUPPORT; - } - - // TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser - - CMISScope[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES; - CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext(); - functionContext.setCmisDictionaryService(cmisDictionaryService); - functionContext.setNodeService(nodeService); - functionContext.setValidScopes(validScopes); - - CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport); - Query query = parser.parse(new LuceneQueryModelFactory(), functionContext); - - Map wrapped = new HashMap(); - for (Set group : query.getSource().getSelectorGroups(functionContext)) - { - for (String selector : group) - { - wrapped.put(selector, rs); - } - } - LimitBy limitBy = null; - limitBy = rs.getResultSetMetaData().getLimitedBy(); - - CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService); - return cmis; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#query(java.lang.String) - */ - @Override - public CMISResultSet query(String query) - { - CMISQueryOptions options = new CMISQueryOptions(query, cmisService.getDefaultRootStoreRef()); - return query(options); - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getQuerySupport() - */ - @Override - public CMISQueryEnum getQuerySupport() - { - return CMISQueryEnum.BOTH_COMBINED; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getJoinSupport() - */ - @Override - public CMISJoinEnum getJoinSupport() - { - return CMISJoinEnum.NO_JOIN_SUPPORT; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getPwcSearchable() - */ - @Override - public boolean getPwcSearchable() - { - return true; - } - - /* (non-Javadoc) - * @see org.alfresco.cmis.CMISQueryService#getAllVersionsSearchable() - */ - @Override - public boolean getAllVersionsSearchable() - { - return false; - } - - -} diff --git a/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryAfterInvocationProvider.java b/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryAfterInvocationProvider.java index e3de6b0743..90c2db7d52 100644 --- a/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryAfterInvocationProvider.java +++ b/source/java/org/alfresco/repo/security/permissions/impl/acegi/ACLEntryAfterInvocationProvider.java @@ -35,7 +35,7 @@ import net.sf.acegisecurity.ConfigAttribute; import net.sf.acegisecurity.ConfigAttributeDefinition; import net.sf.acegisecurity.afterinvocation.AfterInvocationProvider; -import org.alfresco.cmis.CMISResultSet; +import org.alfresco.opencmis.search.CMISResultSet; import org.alfresco.repo.search.SimpleResultSetMetaData; import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet; import org.alfresco.repo.search.impl.lucene.SolrJSONResultSet; diff --git a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java index 55e8d13238..4c5ec38a63 100644 --- a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java +++ b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java @@ -20,10 +20,9 @@ package org.alfresco.repo.service; import java.util.Collection; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISServices; import org.alfresco.mbeans.VirtServerRegistry; +import org.alfresco.opencmis.dictionary.CMISDictionaryService; +import org.alfresco.opencmis.search.CMISQueryService; import org.alfresco.repo.admin.SysAdminParams; import org.alfresco.repo.forms.FormService; import org.alfresco.repo.imap.ImapService; @@ -476,12 +475,6 @@ public class ServiceDescriptorRegistry return (InvitationService)getService(INVITATION_SERVICE); } - @Override - public CMISServices getCMISService() - { - return (CMISServices)getService(CMIS_SERVICE); - } - @Override public CMISDictionaryService getCMISDictionaryService() { diff --git a/source/java/org/alfresco/service/ServiceRegistry.java b/source/java/org/alfresco/service/ServiceRegistry.java index 7d79b2ab4f..b6ca6afacb 100644 --- a/source/java/org/alfresco/service/ServiceRegistry.java +++ b/source/java/org/alfresco/service/ServiceRegistry.java @@ -21,10 +21,9 @@ package org.alfresco.service; import java.util.Collection; import org.alfresco.api.AlfrescoPublicApi; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISServices; import org.alfresco.mbeans.VirtServerRegistry; +import org.alfresco.opencmis.dictionary.CMISDictionaryService; +import org.alfresco.opencmis.search.CMISQueryService; import org.alfresco.repo.admin.SysAdminParams; import org.alfresco.repo.forms.FormService; import org.alfresco.repo.imap.ImapService; @@ -557,13 +556,6 @@ public interface ServiceRegistry @NotAuditable InvitationService getInvitationService(); - /** - * Get the CMIS service (or null if one is not provided) - * @return the CMIS service - */ - @NotAuditable - CMISServices getCMISService(); - /** * Get the CMIS Dictionary service (or null if one is not provided) * @return the CMIS Dictionary service diff --git a/source/test-java/org/alfresco/AllUnitTestsSuite.java b/source/test-java/org/alfresco/AllUnitTestsSuite.java index 79925c465f..9107d60b2f 100644 --- a/source/test-java/org/alfresco/AllUnitTestsSuite.java +++ b/source/test-java/org/alfresco/AllUnitTestsSuite.java @@ -24,7 +24,6 @@ public class AllUnitTestsSuite extends TestSuite static void unitTests(TestSuite suite) { suite.addTest(new JUnit4TestAdapter(org.alfresco.opencmis.AlfrescoCmisExceptionInterceptorTest.class)); - suite.addTestSuite(org.alfresco.cmis.PropertyFilterTest.class); suite.addTestSuite(org.alfresco.encryption.EncryptorTest.class); suite.addTestSuite(org.alfresco.encryption.KeyStoreKeyProviderTest.class); suite.addTest(new JUnit4TestAdapter(org.alfresco.filesys.config.ServerConfigurationBeanTest.class)); diff --git a/source/test-java/org/alfresco/Repository01TestSuite.java b/source/test-java/org/alfresco/Repository01TestSuite.java index 36a8fca2a4..9a1c576b93 100644 --- a/source/test-java/org/alfresco/Repository01TestSuite.java +++ b/source/test-java/org/alfresco/Repository01TestSuite.java @@ -49,15 +49,6 @@ public class Repository01TestSuite extends TestSuite suite.addTestSuite(org.alfresco.RepositoryStartStopTest.class); } - static void tests2(TestSuite suite) - { - suite.addTestSuite(org.alfresco.cmis.acl.CMISAccessControlServiceTest.class); - suite.addTestSuite(org.alfresco.cmis.dictionary.CMISDictionaryTest.class); - suite.addTestSuite(org.alfresco.cmis.mapping.CMISPropertyServiceTest.class); - suite.addTestSuite(org.alfresco.cmis.renditions.CMISRenditionServiceTest.class); - suite.addTestSuite(org.alfresco.cmis.search.QueryTest.class); - } - static void tests3(TestSuite suite) // tests="76" time="82.566" { suite.addTestSuite(org.alfresco.email.server.EmailServiceImplTest.class); diff --git a/source/test-java/org/alfresco/Repository02TestSuite.java b/source/test-java/org/alfresco/Repository02TestSuite.java deleted file mode 100644 index 23c94c650a..0000000000 --- a/source/test-java/org/alfresco/Repository02TestSuite.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2005-2014 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 . - */ -package org.alfresco; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * See {@link RepositoryMisc01TestSuite} - * - * @Author Alan Davis - */ -public class Repository02TestSuite extends TestSuite -{ - public static Test suite() - { - TestSuite suite = new TestSuite(); - Repository01TestSuite.tests2(suite); - return suite; - } -} diff --git a/source/test-java/org/alfresco/cmis/PropertyFilterTest.java b/source/test-java/org/alfresco/cmis/PropertyFilterTest.java deleted file mode 100644 index d18206d85d..0000000000 --- a/source/test-java/org/alfresco/cmis/PropertyFilterTest.java +++ /dev/null @@ -1,144 +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 . - */ -package org.alfresco.cmis; - -import junit.framework.TestCase; - - -/** - * 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. - * - * @author Dmitry Velichkevich - * @author Arseny Kovalchuk - */ -public class PropertyFilterTest extends TestCase -{ - private static final String NAME_TOKEN = "name"; - - private static final String[] FILTER_TOKENS = new String[] { NAME_TOKEN, "objectId" }; - private static final String[] TOKENS_THAT_ARE_NOT_ALLOWED = new String[] { "ParentId", "parentId", "ParEnTiD", "IsMajorVersion", "iSmAJORvERSION" }; - - private static final String VALID_MATCHE_ALL_FILTER = "*"; - private static final String VALID_FILTER_WITH_NAME = NAME_TOKEN; - private static final String LONG_VALID_FILTER_WITH_SEVERAL_TOKENS = "objectId,name,CreationDate,Created;By"; - private static final String VALID_FILTER_CMIS_WORKBANCH_ALFRESCO_3_4 = "cmis:parentId, cmis:objectId, name, objectId"; - private static final String VALID_FILTER_WITH_SPACES = " name, objectId,CreationDate, CreatedBy , ModifiedBy , LastModifiedBy "; - - private static final String INVALID_MATCHE_ALL_FILTER = "*,"; - private static final String INVALID_FILTER_WITH_NAME = "*name,"; - private static final String INVALID_FILTER_WITH_SEVERAL_TOKENS = "name,,objectId"; - private static final String LONG_INVALID_FILTER_WITH_SEVERAL_TOKENS = "objectId, name CreationDate, CreatedBy*"; - private static final String INVALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS = ",name,objectId,CreationDate"; - private static final String INVALID_FILTER_WITH_DENIED_SYMBOL = "objectId\"name"; - private static final String INVALID_FILTER_WITH_LAST_INVALID_SYMBOL = "objectId,name\\"; - - public void testValidFilters() throws Exception - { - allTokensValidAssertion(new PropertyFilter(null)); - allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_FILTER)); - - onlyNameTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_NAME)); - - nameAndObjectIdTokensAssertionValid(new PropertyFilter(LONG_VALID_FILTER_WITH_SEVERAL_TOKENS)); - nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_CMIS_WORKBANCH_ALFRESCO_3_4)); - nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SPACES)); - } - - public void testInvalidFilters() throws Exception - { - invalidFilterAssertion(INVALID_MATCHE_ALL_FILTER); - invalidFilterAssertion(INVALID_FILTER_WITH_NAME); - invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS); - invalidFilterAssertion(LONG_INVALID_FILTER_WITH_SEVERAL_TOKENS); - invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS); - invalidFilterAssertion(INVALID_FILTER_WITH_DENIED_SYMBOL); - invalidFilterAssertion(INVALID_FILTER_WITH_LAST_INVALID_SYMBOL); - } - - private void nameAndObjectIdTokensAssertionValid(PropertyFilter propertyFilter) - { - for (String token : FILTER_TOKENS) - { - assertTrue(token + " should be allowed", propertyFilter.allow(token)); - } - - for (String token : TOKENS_THAT_ARE_NOT_ALLOWED) - { - assertFalse(token + " should not be allowed", propertyFilter.allow(token)); - } - } - - private void onlyNameTokensAssertionValid(PropertyFilter propertyFilter) - { - for (String token : FILTER_TOKENS) - { - if (!token.equals(NAME_TOKEN)) - { - break; - } - - assertTrue(propertyFilter.allow(token)); - } - - for (String token : TOKENS_THAT_ARE_NOT_ALLOWED) - { - assertFalse(propertyFilter.allow(token)); - } - } - - private void allTokensValidAssertion(PropertyFilter propertyFilter) - { - for (String token : FILTER_TOKENS) - { - assertTrue(propertyFilter.allow(token)); - } - - for (String token : TOKENS_THAT_ARE_NOT_ALLOWED) - { - assertTrue(propertyFilter.allow(token)); - } - } - - private void invalidFilterAssertion(String filterValue) - { - try - { - new PropertyFilter(filterValue); - - fail("Invalid filter \"" + filterValue + "\" was interpreted as valid"); - } - catch (CMISFilterNotValidException e) - { - // Success - } - } - -} diff --git a/source/test-java/org/alfresco/cmis/acl/CMISAccessControlServiceTest.java b/source/test-java/org/alfresco/cmis/acl/CMISAccessControlServiceTest.java deleted file mode 100644 index f893a397a9..0000000000 --- a/source/test-java/org/alfresco/cmis/acl/CMISAccessControlServiceTest.java +++ /dev/null @@ -1,589 +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 . - */ -package org.alfresco.cmis.acl; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.alfresco.cmis.CMISAccessControlEntriesGroupedByPrincipalId; -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.CMISConstraintException; -import org.alfresco.cmis.CMISPermissionDefinition; -import org.alfresco.cmis.CMISPermissionMapping; -import org.alfresco.cmis.acl.CMISAccessControlServiceImpl.AccessPermissionComparator; -import org.alfresco.cmis.mapping.BaseCMISTest; -import org.alfresco.model.ContentModel; -import org.alfresco.opencmis.CMISAccessControlFormatEnum; -import org.alfresco.repo.security.permissions.PermissionReference; -import org.alfresco.service.cmr.repository.NodeRef; -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.test_category.OwnJVMTestsCategory; -import org.junit.experimental.categories.Category; - -/** - * @author andyh - */ -@Category(OwnJVMTestsCategory.class) -public class CMISAccessControlServiceTest extends BaseCMISTest -{ - private NodeRef parent; - - private NodeRef child; - - private NodeRef grandParent; - - public void testAclPropagationMode() - { - assertEquals(CMISAclPropagationEnum.PROPAGATE, cmisAccessControlService.getAclPropagation()); - } - - public void testAclCapability() - { - assertEquals(CMISAclCapabilityEnum.MANAGE, cmisAccessControlService.getAclCapability()); - } - - public void testPermissions() - { - List allPermissions = cmisAccessControlService.getRepositoryPermissions(); - assertEquals(69, allPermissions.size()); - HashSet permissionSet = new HashSet(); - permissionSet.addAll(allPermissions); - assertEquals(69, permissionSet.size()); - - } - - public void testAclReportingCmisPermissionsOnly() throws Exception - { - createTestAcls(); - - CMISAccessControlReport grandParentReport = cmisAccessControlService.getAcl(grandParent, CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS); - assertFalse(grandParentReport.isExact()); - assertEquals(10, grandParentReport.getAccessControlEntries().size()); - assertTrue(checkCounts(grandParentReport, PermissionService.ADMINISTRATOR_AUTHORITY, 1, 2)); - assertTrue(checkCounts(grandParentReport, PermissionService.ALL_AUTHORITIES, 1, 0)); - assertTrue(checkCounts(grandParentReport, "ToMask", 1, 0)); - assertTrue(checkCounts(grandParentReport, "Full", 0, 3)); - assertTrue(checkCounts(grandParentReport, "Reader", 1, 0)); - assertTrue(checkCounts(grandParentReport, "Writer", 1, 0)); - assertTrue(checkAbsent(grandParentReport, "SplitRead")); - assertTrue(checkAbsent(grandParentReport, "SplitWrite")); - assertTrue(checkAbsent(grandParentReport, "DuplicateRead")); - assertTrue(checkAbsent(grandParentReport, "Writer2")); - assertTrue(checkAbsent(grandParentReport, "Multi")); - - CMISAccessControlReport parentReport = cmisAccessControlService.getAcl(parent, CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS); - assertFalse(parentReport.isExact()); - assertEquals(10, parentReport.getAccessControlEntries().size()); - assertTrue(checkCounts(parentReport, PermissionService.ADMINISTRATOR_AUTHORITY, 0, 3)); - assertTrue(checkCounts(parentReport, PermissionService.ALL_AUTHORITIES, 0, 1)); - assertTrue(checkAbsent(parentReport, "ToMask")); - assertTrue(checkCounts(parentReport, "Full", 0, 3)); - assertTrue(checkCounts(parentReport, "Reader", 0, 1)); - assertTrue(checkCounts(parentReport, "Writer", 0, 1)); - assertTrue(checkAbsent(parentReport, "SplitRead")); - assertTrue(checkAbsent(parentReport, "SplitWrite")); - assertTrue(checkCounts(parentReport, "DuplicateRead", 1, 0)); - assertTrue(checkAbsent(parentReport, "Writer2")); - assertTrue(checkAbsent(parentReport, "Multi")); - - CMISAccessControlReport childReport = cmisAccessControlService.getAcl(child, CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(13, childReport.getAccessControlEntries().size()); - assertTrue(checkCounts(childReport, PermissionService.ADMINISTRATOR_AUTHORITY, 0, 3)); - assertTrue(checkCounts(childReport, PermissionService.ALL_AUTHORITIES, 0, 1)); - assertTrue(checkAbsent(childReport, "ToMask")); - assertTrue(checkCounts(childReport, "Full", 0, 3)); - assertTrue(checkCounts(childReport, "Reader", 0, 1)); - assertTrue(checkCounts(childReport, "Writer", 0, 1)); - assertTrue(checkAbsent(childReport, "SplitRead")); - assertTrue(checkAbsent(childReport, "SplitWrite")); - assertTrue(checkCounts(childReport, "DuplicateRead", 1, 0)); - assertTrue(checkCounts(childReport, "Writer2", 1, 0)); - assertTrue(checkCounts(childReport, "Multi", 2, 0)); - } - - private Set getAllPermissions() - { - HashSet answer = new HashSet(); - PermissionReference allPermission = permissionModelDao.getPermissionReference(null, PermissionService.ALL_PERMISSIONS); - Set all = permissionModelDao.getAllPermissions(); - for (PermissionReference pr : all) - { - answer.add(pr.toString()); - } - // Add All - answer.add(allPermission.toString()); - // Add CMIS permissions - answer.add(CMISAccessControlService.CMIS_ALL_PERMISSION); - answer.add(CMISAccessControlService.CMIS_READ_PERMISSION); - answer.add(CMISAccessControlService.CMIS_WRITE_PERMISSION); - return answer; - } - - private boolean checkCounts(CMISAccessControlReport report, String key, int direct, int indirect) throws Exception - { - // check all permissions are valid - - Set permissionNames = getAllPermissions(); - - for (CMISAccessControlEntry entry : report.getAccessControlEntries()) - { - if (!permissionNames.contains(entry.getPermission())) - { - return false; - } - } - - // check counts - - for (CMISAccessControlEntriesGroupedByPrincipalId group : report.getAccessControlEntriesGroupedByPrincipalId()) - { - if (group.getPrincipalId().equals(key)) - { - if (group.getDirectPermissions().size() != direct) - { - return false; - } - if (group.getIndirectPermissions().size() != indirect) - { - return false; - } - return true; - } - } - return false; - } - - private boolean checkAbsent(CMISAccessControlReport report, String key) throws Exception - { - for (CMISAccessControlEntriesGroupedByPrincipalId group : report.getAccessControlEntriesGroupedByPrincipalId()) - { - if (group.getPrincipalId().equals(key)) - { - return false; - } - } - return true; - } - - public void testAclReportingAllPermissions() throws Exception - { - createTestAcls(); - - CMISAccessControlReport grandParentReport = cmisAccessControlService.getAcl(grandParent, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(grandParentReport.isExact()); - assertEquals(17, grandParentReport.getAccessControlEntries().size()); - assertTrue(checkCounts(grandParentReport, PermissionService.ADMINISTRATOR_AUTHORITY, 1, 3)); - assertTrue(checkCounts(grandParentReport, PermissionService.ALL_AUTHORITIES, 1, 1)); - assertTrue(checkCounts(grandParentReport, "ToMask", 1, 1)); - assertTrue(checkCounts(grandParentReport, "Full", 1, 3)); - assertTrue(checkCounts(grandParentReport, "Reader", 1, 1)); - assertTrue(checkCounts(grandParentReport, "Writer", 1, 1)); - assertTrue(checkAbsent(grandParentReport, "SplitRead")); - assertTrue(checkAbsent(grandParentReport, "SplitWrite")); - assertTrue(checkAbsent(grandParentReport, "DuplicateRead")); - assertTrue(checkAbsent(grandParentReport, "Writer2")); - assertTrue(checkCounts(grandParentReport, "Multi", 1, 0)); - - CMISAccessControlReport parentReport = cmisAccessControlService.getAcl(parent, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(parentReport.isExact()); - assertEquals(20, parentReport.getAccessControlEntries().size()); - assertTrue(checkCounts(parentReport, PermissionService.ADMINISTRATOR_AUTHORITY, 0, 4)); - assertTrue(checkCounts(parentReport, PermissionService.ALL_AUTHORITIES, 0, 2)); - assertTrue(checkAbsent(parentReport, "ToMask")); - assertTrue(checkCounts(parentReport, "Full", 0, 4)); - assertTrue(checkCounts(parentReport, "Reader", 0, 2)); - assertTrue(checkCounts(parentReport, "Writer", 0, 2)); - assertTrue(checkCounts(parentReport, "SplitRead", 1, 0)); - assertTrue(checkCounts(parentReport, "SplitWrite", 1, 0)); - assertTrue(checkCounts(parentReport, "DuplicateRead", 1, 1)); - assertTrue(checkAbsent(grandParentReport, "Writer2")); - assertTrue(checkCounts(parentReport, "Multi", 1, 1)); - - CMISAccessControlReport childReport = cmisAccessControlService.getAcl(child, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(29, childReport.getAccessControlEntries().size()); - assertTrue(checkCounts(childReport, PermissionService.ADMINISTRATOR_AUTHORITY, 0, 4)); - assertTrue(checkCounts(childReport, PermissionService.ALL_AUTHORITIES, 0, 2)); - assertTrue(checkAbsent(childReport, "ToMask")); - assertTrue(checkCounts(childReport, "Full", 0, 4)); - assertTrue(checkCounts(childReport, "Reader", 0, 2)); - assertTrue(checkCounts(childReport, "Writer", 0, 2)); - assertTrue(checkCounts(childReport, "SplitRead", 1, 1)); - assertTrue(checkCounts(childReport, "SplitWrite", 1, 1)); - assertTrue(checkCounts(childReport, "DuplicateRead", 1, 1)); - assertTrue(checkCounts(childReport, "Writer2", 1, 1)); - assertTrue(checkCounts(childReport, "Multi", 3, 4)); - - } - - private void createTestAcls() - { - grandParent = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Parent", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(grandParent, ContentModel.PROP_NAME, "GrandParent"); - parent = nodeService.createNode(grandParent, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Child", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(parent, ContentModel.PROP_NAME, "Parent"); - child = nodeService.createNode(parent, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Child", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(child, ContentModel.PROP_NAME, "Child"); - permissionService.setPermission(grandParent, PermissionService.ADMINISTRATOR_AUTHORITY, PermissionService.ALL_PERMISSIONS, true); - permissionService.setPermission(grandParent, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - permissionService.setPermission(grandParent, "ToMask", PermissionService.READ, true); - permissionService.setPermission(grandParent, "Full", PermissionService.FULL_CONTROL, true); - permissionService.setPermission(grandParent, "Writer", PermissionService.WRITE, true); - permissionService.setPermission(grandParent, "Reader", PermissionService.READ, true); - permissionService.setPermission(grandParent, "Multi", PermissionService.DELETE, true); - - permissionService.setPermission(parent, "ToMask", PermissionService.READ, false); - permissionService.setPermission(parent, "SplitRead", PermissionService.READ_PROPERTIES, true); - permissionService.setPermission(parent, "SplitWrite", PermissionService.WRITE_CONTENT, true); - permissionService.setPermission(parent, "DuplicateRead", PermissionService.READ, true); - permissionService.setPermission(parent, "Multi", PermissionService.CREATE_CHILDREN, true); - - permissionService.setPermission(child, "SplitRead", PermissionService.READ_CONTENT, true); - permissionService.setPermission(child, "Writer2", PermissionService.WRITE, true); - permissionService.setPermission(child, "SplitWrite", PermissionService.WRITE_PROPERTIES, true); - permissionService.setPermission(child, "DuplicateRead", PermissionService.READ, true); - permissionService.setPermission(child, "Multi", PermissionService.READ, true); - permissionService.setPermission(child, "Multi", PermissionService.WRITE, true); - permissionService.setPermission(child, "Multi", PermissionService.SET_OWNER, true); - - } - - public void testAccessEntryOrdering() - { - createTestAcls(); - - Set permDefs = new HashSet(); - permDefs.addAll(cmisAccessControlService.getRepositoryPermissions()); - - Set permissions = permissionService.getAllSetPermissions(child); - ArrayList ordered = new ArrayList(); - AccessPermissionComparator comparator = new AccessPermissionComparator(); - for (AccessPermission current : permissions) - { - int index = Collections.binarySearch(ordered, current, comparator); - if (index < 0) - { - ordered.add(-index - 1, current); - } - } - int i = 0; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Full", ordered.get(i).getAuthority()); - - i++; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals(PermissionService.ALL_AUTHORITIES, ordered.get(i).getAuthority()); - - i++; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Multi", ordered.get(i).getAuthority()); - - i++; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals(PermissionService.ADMINISTRATOR_AUTHORITY, ordered.get(i).getAuthority()); - - i++; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Reader", ordered.get(i).getAuthority()); - - i++; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("ToMask", ordered.get(i).getAuthority()); - - i++; - assertEquals(4, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Writer", ordered.get(i).getAuthority()); - - i++; - assertEquals(2, ordered.get(i).getPosition()); - assertEquals(AccessStatus.DENIED, ordered.get(i).getAccessStatus()); - assertEquals("ToMask", ordered.get(i).getAuthority()); - - i++; - assertEquals(2, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("DuplicateRead", ordered.get(i).getAuthority()); - - i++; - assertEquals(2, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Multi", ordered.get(i).getAuthority()); - - i++; - assertEquals(2, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("SplitRead", ordered.get(i).getAuthority()); - - i++; - assertEquals(2, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("SplitWrite", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("DuplicateRead", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Multi", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Multi", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Multi", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("SplitRead", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("SplitWrite", ordered.get(i).getAuthority()); - - i++; - assertEquals(0, ordered.get(i).getPosition()); - assertEquals(AccessStatus.ALLOWED, ordered.get(i).getAccessStatus()); - assertEquals("Writer2", ordered.get(i).getAuthority()); - } - - public void testApplyAcl() throws Exception - { - grandParent = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Parent", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(grandParent, ContentModel.PROP_NAME, "GrandParent"); - parent = nodeService.createNode(grandParent, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Child", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(parent, ContentModel.PROP_NAME, "Parent"); - child = nodeService.createNode(parent, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Child", namespaceService), ContentModel.TYPE_CONTENT).getChildRef(); - nodeService.setProperty(child, ContentModel.PROP_NAME, "Child"); - - List acesToAdd = new ArrayList(); - acesToAdd.add(new CMISAccessControlEntryImpl(PermissionService.ADMINISTRATOR_AUTHORITY, PermissionService.ALL_PERMISSIONS)); - acesToAdd.add(new CMISAccessControlEntryImpl(PermissionService.ALL_AUTHORITIES, PermissionService.READ)); - acesToAdd.add(new CMISAccessControlEntryImpl("ToMask", PermissionService.READ)); - acesToAdd.add(new CMISAccessControlEntryImpl("Full", PermissionService.FULL_CONTROL)); - acesToAdd.add(new CMISAccessControlEntryImpl("Writer", PermissionService.WRITE)); - acesToAdd.add(new CMISAccessControlEntryImpl("Reader", PermissionService.READ)); - - CMISAccessControlReport grandParentReport = cmisAccessControlService.applyAcl(grandParent, null, acesToAdd, CMISAclPropagationEnum.PROPAGATE, - CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(grandParentReport.isExact()); - assertEquals(16, grandParentReport.getAccessControlEntries().size()); - - List acesToRemove = new ArrayList(); - acesToRemove.add(new CMISAccessControlEntryImpl("ToMask", PermissionService.READ)); - - grandParentReport = cmisAccessControlService.applyAcl(grandParent, acesToRemove, null, CMISAclPropagationEnum.PROPAGATE, - CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(grandParentReport.isExact()); - assertEquals(14, grandParentReport.getAccessControlEntries().size()); - - try - { - grandParentReport = cmisAccessControlService.applyAcl(grandParent, acesToRemove, null, CMISAclPropagationEnum.PROPAGATE, - CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - fail("A non existent ACE should not be removable"); - } - catch (CMISConstraintException e) - { - - } - acesToAdd = new ArrayList(); - acesToAdd.add(new CMISAccessControlEntryImpl("SplitRead", permissionModelDao.getPermissionReference(null, PermissionService.READ_PROPERTIES).toString())); - acesToAdd.add(new CMISAccessControlEntryImpl("SplitWrite", permissionModelDao.getPermissionReference(null, PermissionService.WRITE_CONTENT).toString())); - acesToAdd.add(new CMISAccessControlEntryImpl("DuplicateRead", permissionModelDao.getPermissionReference(null, PermissionService.READ).toString())); - - CMISAccessControlReport parentReport = cmisAccessControlService.applyAcl(parent, null, acesToAdd, CMISAclPropagationEnum.PROPAGATE, - CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(parentReport.isExact()); - assertEquals(18, parentReport.getAccessControlEntries().size()); - - acesToAdd = new ArrayList(); - acesToAdd.add(new CMISAccessControlEntryImpl("SplitRead", PermissionService.READ_CONTENT)); - acesToAdd.add(new CMISAccessControlEntryImpl("Writer2", PermissionService.WRITE)); - acesToAdd.add(new CMISAccessControlEntryImpl("SplitWrite", PermissionService.WRITE_PROPERTIES)); - acesToAdd.add(new CMISAccessControlEntryImpl("DuplicateRead", PermissionService.READ)); - - CMISAccessControlReport childReport = cmisAccessControlService.applyAcl(child, null, acesToAdd, CMISAclPropagationEnum.PROPAGATE, - CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(22, childReport.getAccessControlEntries().size()); - - grandParentReport = cmisAccessControlService.getAcl(grandParent, CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS); - assertFalse(grandParentReport.isExact()); - assertEquals(9, grandParentReport.getAccessControlEntries().size()); - - parentReport = cmisAccessControlService.getAcl(parent, CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS); - assertFalse(parentReport.isExact()); - assertEquals(10, parentReport.getAccessControlEntries().size()); - - childReport = cmisAccessControlService.getAcl(child, CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(11, childReport.getAccessControlEntries().size()); - - grandParentReport = cmisAccessControlService.getAcl(grandParent, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(grandParentReport.isExact()); - assertEquals(14, grandParentReport.getAccessControlEntries().size()); - - parentReport = cmisAccessControlService.getAcl(parent, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(parentReport.isExact()); - assertEquals(18, parentReport.getAccessControlEntries().size()); - - childReport = cmisAccessControlService.getAcl(child, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(22, childReport.getAccessControlEntries().size()); - - acesToAdd = new ArrayList(); - acesToAdd.add(new CMISAccessControlEntryImpl("CMISReader", CMISAccessControlService.CMIS_READ_PERMISSION)); - acesToAdd.add(new CMISAccessControlEntryImpl("CMISWriter", CMISAccessControlService.CMIS_WRITE_PERMISSION)); - acesToAdd.add(new CMISAccessControlEntryImpl("CMISAll", CMISAccessControlService.CMIS_ALL_PERMISSION)); - - childReport = cmisAccessControlService.applyAcl(child, null, acesToAdd, CMISAclPropagationEnum.PROPAGATE, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(30, childReport.getAccessControlEntries().size()); - - childReport = cmisAccessControlService.applyAcl(child, acesToAdd, acesToAdd, CMISAclPropagationEnum.PROPAGATE, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(30, childReport.getAccessControlEntries().size()); - - childReport = cmisAccessControlService.applyAcl(child, acesToAdd, null, CMISAclPropagationEnum.PROPAGATE, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - assertFalse(childReport.isExact()); - assertEquals(22, childReport.getAccessControlEntries().size()); - - try - { - childReport = cmisAccessControlService.applyAcl(child, acesToAdd, null, CMISAclPropagationEnum.PROPAGATE, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS); - fail("A non existent ACE should not be removable"); - } - catch (CMISConstraintException e) - { - - } - } - - public void testAllowableActionsAndPermissionMapping() - { - List mappings = cmisAccessControlService.getPermissionMappings(); - assertEquals(29, mappings.size()); - assertTrue(contains(mappings, "canGetDescendents.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadChildren")); - // "canGetFolderTree.Folder" - assertTrue(contains(mappings, "canGetChildren.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadChildren")); - assertTrue(contains(mappings, "canGetParents.Folder", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadProperties")); - assertTrue(contains(mappings, "canGetFolderParent.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadProperties")); - assertTrue(contains(mappings, "canCreateDocument.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.CreateChildren")); - assertTrue(contains(mappings, "canCreateFolder.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.CreateChildren")); - // "canCreateRelationship.Source" - // "canCreateRelationship.Target" - assertTrue(contains(mappings, "canGetProperties.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadProperties")); - // "canGetRenditions.Object" - assertTrue(contains(mappings, "canViewContent.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadContent")); - assertTrue(contains(mappings, "canUpdateProperties.Object", CMISAccessControlService.CMIS_WRITE_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.WriteProperties")); - assertTrue(contains(mappings, "canMove.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.DeleteNode")); - assertTrue(contains(mappings, "canMove.Target", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.CreateChildren")); - // "canMoveObject.Source" - assertTrue(contains(mappings, "canDelete.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.DeleteNode")); - // "canDelete.Folder" - // === SPEC BUG - should really be those below ... - // "canDeleteObject.Object" - // "canDeleteObject.Folder" - assertTrue(contains(mappings, "canSetContent.Document", CMISAccessControlService.CMIS_WRITE_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.WriteContent")); - assertTrue(contains(mappings, "canDeleteContent.Document", CMISAccessControlService.CMIS_WRITE_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.WriteContent")); - assertTrue(contains(mappings, "canDeleteTree.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.DeleteNode")); - assertTrue(contains(mappings, "canAddToFolder.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadProperties")); - assertTrue(contains(mappings, "canAddToFolder.Folder", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.CreateChildren")); - assertTrue(contains(mappings, "canRemoveFromFolder.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.DeleteNode")); - // "canRemoveObjectFromFolder.Folder" - assertTrue(contains(mappings, "canCheckout.Document", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/content/1.0}lockable.CheckOut")); - assertTrue(contains(mappings, "canCancelCheckout.Document", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/content/1.0}workingcopy.CancelCheckOut")); - assertTrue(contains(mappings, "canCheckin.Document", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/content/1.0}workingcopy.CheckIn")); - assertTrue(contains(mappings, "canGetAllVersions.VersionSeries", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.Read")); - // "canGetObjectRelationships.Object" - assertTrue(contains(mappings, "canAddPolicy.Object", CMISAccessControlService.CMIS_WRITE_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.Write")); - assertTrue(contains(mappings, "canAddPolicy.Policy", CMISAccessControlService.CMIS_READ_PERMISSION)); - assertTrue(contains(mappings, "canRemovePolicy.Object", CMISAccessControlService.CMIS_WRITE_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.Write")); - assertTrue(contains(mappings, "canRemovePolicy.Policy", CMISAccessControlService.CMIS_READ_PERMISSION)); - assertTrue(contains(mappings, "canGetAppliedPolicies.Object", CMISAccessControlService.CMIS_READ_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadProperties")); - assertTrue(contains(mappings, "canGetACL.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ReadPermissions")); - assertTrue(contains(mappings, "canApplyACL.Object", CMISAccessControlService.CMIS_ALL_PERMISSION, "{http://www.alfresco.org/model/system/1.0}base.ChangePermissions")); - } - - private boolean contains(List mappings, String key, String... entries) - { - for (CMISPermissionMapping mapping : mappings) - { - if (mapping.getKey().equals(key)) - { - // check entries are all valid - Set permissionNames = getAllPermissions(); - - for (String permission : mapping.getPermissions()) - { - if (!permissionNames.contains(permission)) - { - return false; - } - } - if (entries.length > 0) - { - if (mapping.getPermissions().size() == entries.length) - { - for (String entry : entries) - { - if (!mapping.getPermissions().contains(entry)) - { - return false; - } - } - return true; - } - } - else - { - return true; - } - } - } - return false; - } -} diff --git a/source/test-java/org/alfresco/cmis/dictionary/CMISDictionaryTest.java b/source/test-java/org/alfresco/cmis/dictionary/CMISDictionaryTest.java deleted file mode 100644 index 8a160c973c..0000000000 --- a/source/test-java/org/alfresco/cmis/dictionary/CMISDictionaryTest.java +++ /dev/null @@ -1,83 +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 . - */ -package org.alfresco.cmis.dictionary; - -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.cmis.mapping.BaseCMISTest; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.junit.experimental.categories.Category; - -@Category(OwnJVMTestsCategory.class) -public class CMISDictionaryTest extends BaseCMISTest -{ - public void testAllTypes() - { - for (CMISTypeDefinition type : cmisDictionaryService.getAllTypes()) - { - System.out.println(type); - } - } - - public void testBaseTypes() - { - for (CMISTypeDefinition type : cmisDictionaryService.getBaseTypes()) - { - System.out.println(type); - } - } - public void testSubTypes() - { - for (CMISTypeDefinition type : cmisDictionaryService.getAllTypes()) - { - System.out.println(type.getTypeId() + " children:"); - for (CMISTypeDefinition subType : type.getSubTypes(false)) - { - System.out.println(" " + subType.getTypeId()); - } - System.out.println(type.getTypeId() + " descendants:"); - for (CMISTypeDefinition subType : type.getSubTypes(true)) - { - System.out.println(" " + subType.getTypeId()); - } - } - } - - public void testTypeIds() - { - for (CMISTypeDefinition typeDef : cmisDictionaryService.getAllTypes()) - { - CMISTypeDefinition typeDefLookup = cmisDictionaryService.findType(typeDef.getTypeId()); - assertNotNull(typeDefLookup); - assertEquals(typeDef, typeDefLookup); - } - } - - public void testBasicPropertyDefinitions() - { - for (CMISTypeDefinition type : cmisDictionaryService.getAllTypes()) - { - System.out.println(type.getTypeId() + " properties:"); - for (CMISPropertyDefinition proDef : type.getPropertyDefinitions().values()) - { - System.out.println(" " + proDef); - } - } - } -} diff --git a/source/test-java/org/alfresco/cmis/mapping/BaseCMISTest.java b/source/test-java/org/alfresco/cmis/mapping/BaseCMISTest.java deleted file mode 100644 index 33fee752ef..0000000000 --- a/source/test-java/org/alfresco/cmis/mapping/BaseCMISTest.java +++ /dev/null @@ -1,179 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.util.Date; - -import javax.transaction.Status; -import javax.transaction.UserTransaction; - -import junit.framework.TestCase; - -import org.alfresco.cmis.CMISAccessControlService; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISRenditionService; -import org.alfresco.cmis.CMISServices; -import org.alfresco.repo.dictionary.DictionaryDAO; -import org.alfresco.repo.dictionary.NamespaceDAOImpl; -import org.alfresco.repo.model.Repository; -import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.MutableAuthenticationDao; -import org.alfresco.repo.security.permissions.impl.ModelDAO; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.action.ActionService; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.rule.RuleService; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.cmr.thumbnail.ThumbnailService; -import org.alfresco.service.cmr.version.VersionService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; - -/** - * Base CMIS test - * Basic TX control and authentication - * - * @author andyh - */ -public abstract class BaseCMISTest extends TestCase -{ - private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - - protected CMISMapping cmisMapping; - protected CMISServices cmisService; - protected CMISDictionaryService cmisDictionaryService; - protected CMISRenditionService cmisRenditionService; - protected CMISAccessControlService cmisAccessControlService; - protected DictionaryService dictionaryService; - protected TransactionService transactionService; - protected AuthenticationComponent authenticationComponent; - protected UserTransaction testTX; - protected NodeService nodeService; - protected NodeRef rootNodeRef; - protected FileFolderService fileFolderService; - protected ServiceRegistry serviceRegistry; - protected NamespaceService namespaceService; - protected CMISQueryService cmisQueryService; - private MutableAuthenticationService authenticationService; - private MutableAuthenticationDao authenticationDAO; - protected SearchService searchService; - protected ContentService contentService; - protected PermissionService permissionService; - protected ThumbnailService thumbnailService; - protected ModelDAO permissionModelDao; - protected DictionaryDAO dictionaryDAO; - protected NamespaceDAOImpl namespaceDao; - protected VersionService versionService; - protected ActionService actionService; - protected RuleService ruleService; - protected Repository repositoryHelper; - - public void setUp() throws Exception - { - serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); - - cmisDictionaryService = (CMISDictionaryService) ctx.getBean("CMISDictionaryService"); - cmisMapping = (CMISMapping) ctx.getBean("CMISMapping"); - cmisQueryService = (CMISQueryService) ctx.getBean("CMISQueryService"); - cmisService = (CMISServices) ctx.getBean("CMISService"); - cmisRenditionService = (CMISRenditionService) ctx.getBean("CMISRenditionService"); - cmisAccessControlService = (CMISAccessControlService) ctx.getBean("CMISAccessControlService"); - dictionaryService = (DictionaryService) ctx.getBean("dictionaryService"); - nodeService = (NodeService) ctx.getBean("nodeService"); - fileFolderService = (FileFolderService) ctx.getBean("fileFolderService"); - namespaceService = (NamespaceService) ctx.getBean("namespaceService"); - - transactionService = (TransactionService) ctx.getBean("transactionComponent"); - authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); - - searchService = (SearchService) ctx.getBean("searchService"); - - contentService = (ContentService) ctx.getBean("contentService"); - - permissionService = (PermissionService) ctx.getBean("permissionService"); - - versionService = (VersionService) ctx.getBean("versionService"); - - actionService = (ActionService)ctx.getBean("actionService"); - ruleService = (RuleService)ctx.getBean("ruleService"); - - repositoryHelper = (Repository)ctx.getBean("repositoryHelper"); - - authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); - authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao"); - - thumbnailService = (ThumbnailService) ctx.getBean("thumbnailService"); - - permissionModelDao = (ModelDAO) ctx.getBean("permissionsModelDAO"); - - dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO"); - namespaceDao = (NamespaceDAOImpl) ctx.getBean("namespaceDAO"); - - testTX = transactionService.getUserTransaction(); - testTX.begin(); - this.authenticationComponent.setSystemUserAsCurrentUser(); - - String storeName = "CMISTest-" + getStoreName() + "-" + (new Date().getTime()); - StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, storeName); - rootNodeRef = nodeService.getRootNode(storeRef); - - if(authenticationDAO.userExists("cmis")) - { - authenticationService.deleteAuthentication("cmis"); - } - authenticationService.createAuthentication("cmis", "cmis".toCharArray()); - } - - private String getStoreName() - { - String testName = getName(); - testName = testName.replace("_", "-"); - testName = testName.replace("%", "-"); - return testName; - - } - - protected void runAs(String userName) - { - authenticationService.authenticate(userName, userName.toCharArray()); - assertNotNull(authenticationService.getCurrentUserName()); - } - - @Override - protected void tearDown() throws Exception - { - if (testTX.getStatus() == Status.STATUS_ACTIVE) - { - testTX.rollback(); - } - AuthenticationUtil.clearCurrentSecurityContext(); - super.tearDown(); - } -} diff --git a/source/test-java/org/alfresco/cmis/mapping/CMISPropertyServiceTest.java b/source/test-java/org/alfresco/cmis/mapping/CMISPropertyServiceTest.java deleted file mode 100644 index fdafd8cc15..0000000000 --- a/source/test-java/org/alfresco/cmis/mapping/CMISPropertyServiceTest.java +++ /dev/null @@ -1,922 +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 . - */ -package org.alfresco.cmis.mapping; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.alfresco.cmis.CMISConstraintException; -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISInvalidArgumentException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator; -import org.alfresco.repo.action.executer.AddFeaturesActionExecuter; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; -import org.alfresco.repo.version.VersionModel; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.lock.LockType; -import org.alfresco.service.cmr.model.FileInfo; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.rule.Rule; -import org.alfresco.service.cmr.rule.RuleType; -import org.alfresco.service.cmr.version.Version; -import org.alfresco.service.cmr.version.VersionType; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; -import org.junit.experimental.categories.Category; -import org.springframework.extensions.webscripts.GUID; - -@Category(OwnJVMTestsCategory.class) -public class CMISPropertyServiceTest extends BaseCMISTest -{ - public void testBasicFolder() throws Exception - { - NodeRef folder = fileFolderService.create(cmisService.getDefaultRootNodeRef(), "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - Map properties = cmisService.getProperties(folder); - assertEquals(folder.toString(), properties.get(CMISDictionaryModel.PROP_OBJECT_ID)); - assertEquals(CMISDictionaryModel.FOLDER_TYPE_ID.getId(), properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID)); - assertEquals(CMISDictionaryModel.FOLDER_TYPE_ID.getId(), properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID)); - assertEquals(authenticationComponent.getCurrentUserName(), properties.get(CMISDictionaryModel.PROP_CREATED_BY)); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(authenticationComponent.getCurrentUserName(), properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY)); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals("BaseFolder", properties.get(CMISDictionaryModel.PROP_NAME)); - - assertNull(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE)); - assertNull(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION)); - assertNull(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION)); - assertNull(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION)); - assertNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertNull(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT)); - assertNull(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY)); - assertNull(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT)); - assertNull(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH)); - assertNull(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME)); - assertNull(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_ID)); - - assertEquals(cmisService.getDefaultRootNodeRef().toString(), properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - } - - public void testBasicDocument() throws Exception - { - NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - - Map properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); // we don't unnecessarily guess/store (see FileFolderService.createImpl) - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - } - - public void testContentProperties() throws Exception - { - NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - - Map properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - ContentData contentData = new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK); - - nodeService.setProperty(content, ContentModel.PROP_CONTENT, contentData); - - ContentWriter writer = serviceRegistry.getContentService().getWriter(content, ContentModel.PROP_CONTENT, true); - writer.setEncoding("UTF-8"); - writer.putContent("The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words; a an and are" - + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: " - + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF"); - long size = writer.getSize(); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), size); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), "text/plain"); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_ID)); - } - - public void testLock() throws Exception - { - NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - - Map properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - serviceRegistry.getLockService().lock(content, LockType.READ_ONLY_LOCK); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - - serviceRegistry.getLockService().unlock(content); - properties = cmisService.getProperties(content); - - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); // we don't unnecessarily guess/store (see FileFolderService.createImpl) - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - } - - public void testCheckOut() throws Exception - { - NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - - Map properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - NodeRef pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - - properties = cmisService.getProperties(pwc); - - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent (Working Copy)"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent (Working Copy)"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - serviceRegistry.getCheckOutCheckInService().cancelCheckout(pwc); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - - properties = cmisService.getProperties(pwc); - - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent (Working Copy)"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent (Working Copy)"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - serviceRegistry.getCheckOutCheckInService().checkin(pwc, null); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - } - - public void testVersioning() throws Exception - { - NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef(); - - Map properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - nodeService.addAspect(content, ContentModel.ASPECT_VERSIONABLE, null); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - NodeRef pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - - properties = cmisService.getProperties(pwc); - - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent (Working Copy)"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent (Working Copy)"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - serviceRegistry.getCheckOutCheckInService().cancelCheckout(pwc); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - - properties = cmisService.getProperties(pwc); - - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent (Working Copy)"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent (Working Copy)"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - Map versionProperties = new HashMap(); - versionProperties.put(Version.PROP_DESCRIPTION, "Meep"); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); - serviceRegistry.getCheckOutCheckInService().checkin(pwc, versionProperties); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL), "1.0"); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - pwc = serviceRegistry.getCheckOutCheckInService().checkout(content); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL), "1.0"); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - - properties = cmisService.getProperties(pwc); - - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent (Working Copy)"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertNotNull(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL)); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), authenticationComponent.getCurrentUserName()); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), pwc.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CHECKIN_COMMENT), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent (Working Copy)"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - versionProperties = new HashMap(); - versionProperties.put(Version.PROP_DESCRIPTION, "Woof"); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); - serviceRegistry.getCheckOutCheckInService().checkin(pwc, versionProperties); - - properties = cmisService.getProperties(content); - assertEquals(properties.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.DOCUMENT_TYPE_ID.getId()); - assertEquals(properties.get(CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(properties.get(CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(properties.get(CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(properties.get(CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(properties.get(CMISDictionaryModel.PROP_NAME), "BaseContent"); - - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_IMMUTABLE), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_VERSION), true); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_LABEL), "1.1"); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_ID), content.toString()); - assertEquals(properties.get(CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT), false); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID), null); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH), 0L); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE), ""); - assertEquals(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME), "BaseContent"); - - assertNull(properties.get(CMISDictionaryModel.PROP_PARENT_ID)); - assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - } - - public void testSinglePropertyFolderAccess() throws Exception - { - NodeRef folder = fileFolderService.create(rootNodeRef, "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef(); - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_ID), folder.toString()); - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_TYPE_ID), CMISDictionaryModel.FOLDER_TYPE_ID.getId()); - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_BASE_TYPE_ID), CMISDictionaryModel.FOLDER_TYPE_ID.getId()); - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_CREATED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_CREATION_DATE)); - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_LAST_MODIFIED_BY), authenticationComponent.getCurrentUserName()); - assertNotNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_LAST_MODIFICATION_DATE)); - assertNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_CHANGE_TOKEN)); - - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_NAME), "BaseFolder"); - - try - { - cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_IMMUTABLE); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_LATEST_VERSION); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_MAJOR_VERSION); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_LABEL); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_ID); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_IS_VERSION_SERIES_CHECKED_OUT); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_BY); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_VERSION_SERIES_CHECKED_OUT_ID); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_CHECKIN_COMMENT); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_LENGTH); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_FILENAME); - cmisService.getProperty(folder, CMISDictionaryModel.PROP_CONTENT_STREAM_ID); - fail("Failed to catch invalid property on type folder"); - } - catch(CMISInvalidArgumentException e) - { - // NOTE: Invalid property - } - - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_PARENT_ID), rootNodeRef.toString()); - assertNull(cmisService.getProperty(folder, CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS)); - - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_NAME.toUpperCase()), "BaseFolder"); - assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_NAME.toLowerCase()), "BaseFolder"); - } - - public void testContentMimeTypeDetection() throws Exception - { - // create simple text plain content - NodeRef content = fileFolderService.create(rootNodeRef, "textFile" + GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); - ContentWriter writer = serviceRegistry.getContentService().getWriter(content, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); - writer.putContent("Simple text plain document"); - - // create content stream with undefined mimetype and file name - ContentStreamImpl contentStreamHTML = new ContentStreamImpl(null, null, " Hello

Test html

"); - String objectId = (String) cmisService.getProperty(content, CMISDictionaryModel.PROP_OBJECT_ID); - - cmisService.setContentStream(objectId, null, true, contentStreamHTML.getStream(), null); - - // check mimetype - String mimetype = (String) cmisService.getProperty(content, CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE); - assertTrue("Mimetype is not defined correctly.", mimetype.equals(MimetypeMap.MIMETYPE_HTML)); - } - - /** - * Test for ALF-18151. - */ - public void testDeleteFolder() throws Exception - { - Map testFolderMap = new HashMap(4); - - try - { - // create folder with file - String folderName = "cmistestfolder" + GUID.generate(); - String docName = "cmistestdoc.txt" + GUID.generate(); - FileInfo folder = createContent(folderName, docName, false); - testFolderMap.put(folder, Boolean.FALSE); - - // create empty folder - String folderNameEmpty = "cmistestfolder_empty1" + GUID.generate(); - FileInfo folderEmpty = createContent(folderNameEmpty, null, false); - testFolderMap.put(folderEmpty, Boolean.TRUE); - - // create folder with file - String folderNameRule = "cmistestfolde_rule" + GUID.generate(); - String docNameRule = "cmistestdoc_rule.txt" + GUID.generate(); - FileInfo folderWithRule = createContent(folderNameRule, docNameRule, true); - testFolderMap.put(folderWithRule, Boolean.FALSE); - - // create empty folder - String folderNameEmptyRule = "cmistestfolde_empty_rule1" + GUID.generate(); - FileInfo folderEmptyWithRule = createContent(folderNameEmptyRule, null, true); - testFolderMap.put(folderEmptyWithRule, Boolean.TRUE); - - for (Map.Entry entry : testFolderMap.entrySet()) - { - try - { - // delete folder - cmisService.deleteObject((String) cmisService.getProperty(entry.getKey().getNodeRef(), CMISDictionaryModel.PROP_OBJECT_ID), Boolean.TRUE); - } - catch (CMISConstraintException ex) - { - assertTrue(!entry.getValue()); - continue; - } - - assertTrue(entry.getValue()); - } - - } - finally - { - for (Map.Entry entry : testFolderMap.entrySet()) - { - if (fileFolderService.exists(entry.getKey().getNodeRef())) - { - fileFolderService.delete(entry.getKey().getNodeRef()); - } - } - } - } - - private FileInfo createContent(final String folderName, final String docName, final boolean isRule) - { - final FileInfo folderInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() - { - @Override - public FileInfo execute() throws Throwable - { - NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome(); - - FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER); - nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName); - assertNotNull(folderInfo); - - FileInfo fileInfo; - if (docName != null) - { - fileInfo = fileFolderService.create(folderInfo.getNodeRef(), docName, ContentModel.TYPE_CONTENT); - nodeService.setProperty(fileInfo.getNodeRef(), ContentModel.PROP_NAME, docName); - assertNotNull(fileInfo); - } - - if (isRule) - { - Rule rule = addRule(true, folderName); - - assertNotNull(rule); - - // Attach the rule to the node - ruleService.saveRule(folderInfo.getNodeRef(), rule); - - assertTrue(ruleService.getRules(folderInfo.getNodeRef()).size() > 0); - } - - return folderInfo; - } - }); - - return folderInfo; - } - - private Rule addRule(boolean isAppliedToChildren, String title) - { - - // Rule properties - Map conditionProps = new HashMap(); - conditionProps.put(ComparePropertyValueEvaluator.PARAM_VALUE, ".txt"); - - Map actionProps = new HashMap(); - actionProps.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE); - - List ruleTypes = new ArrayList(1); - ruleTypes.add(RuleType.INBOUND); - - // Create the action - org.alfresco.service.cmr.action.Action action = actionService.createAction(title); - action.setParameterValues(conditionProps); - - ActionCondition actionCondition = actionService.createActionCondition(ComparePropertyValueEvaluator.NAME); - actionCondition.setParameterValues(conditionProps); - action.addActionCondition(actionCondition); - - // Create the rule - Rule rule = new Rule(); - rule.setRuleTypes(ruleTypes); - rule.setTitle(title); - rule.setDescription("description"); - rule.applyToChildren(isAppliedToChildren); - rule.setAction(action); - - return rule; - } -} diff --git a/source/test-java/org/alfresco/cmis/renditions/CMISRenditionServiceTest.java b/source/test-java/org/alfresco/cmis/renditions/CMISRenditionServiceTest.java deleted file mode 100644 index 380e629d8c..0000000000 --- a/source/test-java/org/alfresco/cmis/renditions/CMISRenditionServiceTest.java +++ /dev/null @@ -1,389 +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 . - */ -package org.alfresco.cmis.renditions; - -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.Serializable; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import org.alfresco.cmis.CMISRendition; -import org.alfresco.cmis.mapping.BaseCMISTest; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.transform.AbstractContentTransformerTest; -import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; -import org.alfresco.repo.thumbnail.ThumbnailDefinition; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NoTransformerException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.TransformationOptions; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.junit.experimental.categories.Category; - -/** - * @author Stas Sokolovsky - */ -@Category(OwnJVMTestsCategory.class) -public class CMISRenditionServiceTest extends BaseCMISTest -{ - private static final String[] THUMBNAIL_NAMES = new String[] { "doclib", "webpreview", "imgpreview" }; - private static final String[] THUMBNAIL_KINDS = new String[] { "cmis:thumbnail", "alf:webpreview", "alf:webpreview" }; - - private NodeRef document; - private List documentRenditions = new ArrayList(); - private CMISRendition icon16Rendition = new CMISRenditionImpl(null, "alf:icon16", "image/gif", "alf:icon16", 16, 16, null, null, null); - private CMISRendition icon32Rendition = new CMISRenditionImpl(null, "alf:icon32", "image/gif", "alf:icon32", 32, 32, null, null, null); - - public void setUp() throws Exception - { - super.setUp(); - - String documentName = "TestDocument" + System.currentTimeMillis(); - document = createPdfDocument(documentName); - - documentRenditions = new ArrayList(); - for (int i = 0; i < THUMBNAIL_NAMES.length; ++i) - { - documentRenditions.add(createRendition(document, THUMBNAIL_NAMES[i], THUMBNAIL_KINDS[i])); - } - } - - public void testGetAllRenditions() throws Exception - { - List receivedRenditions = cmisRenditionService.getRenditions(document, "*"); - - List expectedRenditions = new ArrayList(); - expectedRenditions.addAll(documentRenditions); - expectedRenditions.add(icon16Rendition); - expectedRenditions.add(icon32Rendition); - - assertRendiions(receivedRenditions, expectedRenditions); - } - - public void testGetRenditionsByKind() throws Exception - { - testGetRenditionsByKind("cmis:thumbnail"); - testGetRenditionsByKind("alf:webpreview"); - testGetRenditionsByKind("alf:icon16"); - testGetRenditionsByKind("alf:icon32"); - - testGetRenditionsByKind("alf:webpreview", "alf:icon32"); - testGetRenditionsByKind("cmis:thumbnail", "alf:webpreview", "alf:icon16", "alf:icon32"); - } - - public void testGetRenditionsByMimetype() throws Exception - { - for (CMISRendition rendition : documentRenditions) - { - testGetRenditionsByMimetype(rendition.getMimeType()); - } - testGetRenditionsByMimetype(icon16Rendition.getMimeType()); - testGetRenditionsByMimetype(icon32Rendition.getMimeType()); - - String[] mimetypes = getDifferentMimetypes(); - testGetRenditionsByMimetype(mimetypes); - } - - public void testEmptyFilter() throws Exception - { - List receivedRenditions = cmisRenditionService.getRenditions(document, null); - assertTrue(receivedRenditions == null || receivedRenditions.size() == 0); - - receivedRenditions = cmisRenditionService.getRenditions(document, "cmis:none"); - assertTrue(receivedRenditions == null || receivedRenditions.size() == 0); - } - - public void testRenditionsByBaseMimetype() throws Exception - { - String[] mimetypes = getDifferentMimetypes(); - List baseMimetypeFilters = new ArrayList(); - for (String mimetype : mimetypes) - { - String baseMimetype = getBaseType(mimetype); - String filter = baseMimetype + "/*"; - baseMimetypeFilters.add(filter); - - testGetRenditionsByMimetype(filter); - } - - testGetRenditionsByMimetype(baseMimetypeFilters.toArray(new String[0])); - } - - public void testMixedFilter() throws Exception - { - String[] mimetypes = getDifferentMimetypes(); - testGetRenditions(THUMBNAIL_KINDS, mimetypes); - } - - private void testGetRenditionsByMimetype(String... mimetypes) throws Exception - { - testGetRenditions(null, mimetypes); - } - - private void testGetRenditionsByKind(String... kinds) throws Exception - { - testGetRenditions(kinds, null); - } - - private void testGetRenditions(String[] kinds, String[] mimetypes) throws Exception - { - String filter = createFilter(kinds, mimetypes); - List receivedRenditions = cmisRenditionService.getRenditions(document, filter); - - List expectedRenditions = new ArrayList(); - if (kinds != null) - { - for (String kind : kinds) - { - expectedRenditions.addAll(getRenditionsByKind(kind)); - } - } - if (mimetypes != null) - { - for (String mimetype : mimetypes) - { - expectedRenditions.addAll(getRenditionsByMimetype(mimetype)); - } - } - - assertRendiions(receivedRenditions, expectedRenditions); - } - - protected void tearDown() throws Exception - { - fileFolderService.delete(document); - super.tearDown(); - } - - private CMISRendition createRendition(NodeRef nodeRef, String thumbnailName, String kind) - { - ThumbnailDefinition details = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(thumbnailName); - NodeRef thumbnailNodeRef = thumbnailService.createThumbnail(nodeRef, ContentModel.PROP_CONTENT, details.getMimetype(), details.getTransformationOptions(), details - .getName()); - - CMISRenditionImpl rendition = new CMISRenditionImpl(); - rendition.setStreamId(thumbnailNodeRef.toString()); - rendition.setKind(kind); - rendition.setMimeType(details.getMimetype()); - if (details.getTransformationOptions() instanceof ImageTransformationOptions) - { - ImageTransformationOptions imageOptions = (ImageTransformationOptions) details.getTransformationOptions(); - rendition.setWidth(imageOptions.getResizeOptions().getWidth()); - rendition.setHeight(imageOptions.getResizeOptions().getHeight()); - } - - return rendition; - } - - private NodeRef createPdfDocument(final String nodeName) - { - Map props = new HashMap(); - props.put(ContentModel.PROP_NAME, nodeName); - NodeRef result = nodeService.createNode(rootNodeRef, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName), - ContentModel.TYPE_CONTENT, - props).getChildRef(); - - File file = loadQuickPdfFile(); - - // Set the content - ContentWriter writer = contentService.getWriter(result, ContentModel.PROP_CONTENT, true); - writer.setMimetype(MimetypeMap.MIMETYPE_PDF); - writer.setEncoding("UTF-8"); - - writer.putContent(file); - - return result; - } - - private File loadQuickPdfFile() - { - URL url = AbstractContentTransformerTest.class.getClassLoader().getResource("quick/quick.pdf"); - if (url == null) - { - fail("Could not load pdf file"); - } - File file = new File(url.getFile()); - if (!file.exists()) - { - fail("Could not load pdf file"); - } - return file; - } - - private void assertRendiions(List receivedRenditions, List expectedRenditions) - { - assertNotNull(receivedRenditions); - expectedRenditions = removeReplication(expectedRenditions); - assertTrue(receivedRenditions.size() == expectedRenditions.size()); - - for (CMISRendition rendition : receivedRenditions) - { - assertNotNull(rendition); - assertNotNull(rendition.getStreamId()); - } - - Collections.sort(receivedRenditions, renditionsComparator); - Collections.sort(expectedRenditions, renditionsComparator); - - for (int i = 0; i < expectedRenditions.size(); ++i) - { - assertRendition(receivedRenditions.get(i), expectedRenditions.get(i)); - } - } - - private void assertRendition(CMISRendition receivedRendition, CMISRendition expectedRendition) - { - assertEquals(expectedRendition.getStreamId(), receivedRendition.getStreamId()); - assertEquals(expectedRendition.getKind(), receivedRendition.getKind()); - assertEquals(expectedRendition.getMimeType(), receivedRendition.getMimeType()); - assertEquals(expectedRendition.getWidth(), receivedRendition.getWidth()); - assertEquals(expectedRendition.getHeight(), receivedRendition.getHeight()); - } - - private List removeReplication(List renditions) - { - return new ArrayList(new HashSet(renditions)); - } - - private Comparator renditionsComparator = new Comparator() - { - public int compare(CMISRendition rendition1, CMISRendition rendition2) - { - return rendition1.getStreamId().compareTo(rendition2.getStreamId()); - } - }; - - private List getRenditionsByKind(String kind) - { - return getRenditions(kind, null); - } - - private List getRenditionsByMimetype(String mimetype) - { - return getRenditions(null, mimetype); - } - - private List getRenditions(String kind, String mimetype) - { - List result = new ArrayList(); - - List allRenditions = new ArrayList(documentRenditions); - allRenditions.add(icon16Rendition); - allRenditions.add(icon32Rendition); - for (CMISRendition rendition : allRenditions) - { - if (isRenditionSatisfyConditions(rendition, kind, mimetype)) - { - result.add(rendition); - } - } - return result; - } - - private boolean isRenditionSatisfyConditions(CMISRendition rendition, String kind, String mimetype) - { - if (kind != null) - { - if (!kind.equals(rendition.getKind())) - { - return false; - } - } - if (mimetype != null) - { - if (mimetype.endsWith("/*")) - { - String baseMimetype = getBaseType(mimetype); - if (!rendition.getMimeType().startsWith(baseMimetype)) - { - return false; - } - } - else if (!mimetype.equals(rendition.getMimeType())) - { - return false; - } - } - return true; - } - - private String[] getDifferentMimetypes() - { - List allRenditions = new ArrayList(documentRenditions); - allRenditions.add(icon16Rendition); - allRenditions.add(icon32Rendition); - Set mimetypes = new HashSet(); - for (CMISRendition rendition : allRenditions) - { - mimetypes.add(rendition.getMimeType()); - } - return mimetypes.toArray(new String[0]); - } - - private String getBaseType(String mimetype) - { - String baseMymetype = mimetype; - int subTypeIndex = mimetype.indexOf("/"); - if (subTypeIndex > 0 || subTypeIndex < mimetype.length()) - { - baseMymetype = mimetype.substring(0, subTypeIndex); - } - return baseMymetype; - } - - private String createFilter(String[] kinds, String[] mimetypes) - { - StringBuilder filter = new StringBuilder(); - if (kinds != null) - { - for (String kind : kinds) - { - filter.append(kind); - filter.append(","); - } - } - if (mimetypes != null) - { - for (String mimetype : mimetypes) - { - filter.append(mimetype); - filter.append(","); - } - } - filter.delete(filter.length() - 1, filter.length()); - return filter.toString(); - } - -} diff --git a/source/test-java/org/alfresco/cmis/search/QueryTest.java b/source/test-java/org/alfresco/cmis/search/QueryTest.java deleted file mode 100644 index 2405546810..0000000000 --- a/source/test-java/org/alfresco/cmis/search/QueryTest.java +++ /dev/null @@ -1,5846 +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 . - */ -package org.alfresco.cmis.search; - -import java.io.InputStream; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.text.Collator; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import org.alfresco.cmis.CMISCardinalityEnum; -import org.alfresco.cmis.CMISDataTypeEnum; -import org.alfresco.cmis.CMISDictionaryModel; -import org.alfresco.cmis.CMISPropertyDefinition; -import org.alfresco.cmis.CMISQueryException; -import org.alfresco.cmis.CMISQueryOptions; -import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode; -import org.alfresco.cmis.CMISResultSet; -import org.alfresco.cmis.CMISResultSetColumn; -import org.alfresco.cmis.CMISResultSetMetaData; -import org.alfresco.cmis.CMISResultSetRow; -import org.alfresco.cmis.CMISTypeDefinition; -import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService; -import org.alfresco.cmis.mapping.BaseCMISTest; -import org.alfresco.cmis.mapping.BaseTypeIdProperty; -import org.alfresco.cmis.mapping.CheckinCommentProperty; -import org.alfresco.cmis.mapping.ContentStreamIdProperty; -import org.alfresco.cmis.mapping.ContentStreamLengthProperty; -import org.alfresco.cmis.mapping.ContentStreamMimetypeProperty; -import org.alfresco.cmis.mapping.DirectProperty; -import org.alfresco.cmis.mapping.FixedValueProperty; -import org.alfresco.cmis.mapping.IsImmutableProperty; -import org.alfresco.cmis.mapping.IsLatestMajorVersionProperty; -import org.alfresco.cmis.mapping.IsLatestVersionProperty; -import org.alfresco.cmis.mapping.IsMajorVersionProperty; -import org.alfresco.cmis.mapping.IsVersionSeriesCheckedOutProperty; -import org.alfresco.cmis.mapping.ObjectIdProperty; -import org.alfresco.cmis.mapping.ObjectTypeIdProperty; -import org.alfresco.cmis.mapping.ParentProperty; -import org.alfresco.cmis.mapping.PathProperty; -import org.alfresco.cmis.mapping.VersionLabelProperty; -import org.alfresco.cmis.mapping.VersionSeriesCheckedOutByProperty; -import org.alfresco.cmis.mapping.VersionSeriesCheckedOutIdProperty; -import org.alfresco.cmis.mapping.VersionSeriesIdProperty; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.dictionary.M2Model; -import org.alfresco.repo.node.BaseNodeServiceTest; -import org.alfresco.repo.search.MLAnalysisMode; -import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser; -import org.alfresco.repo.search.impl.parsers.CMISLexer; -import org.alfresco.repo.search.impl.parsers.CMISParser; -import org.alfresco.repo.search.impl.parsers.FTSQueryException; -import org.alfresco.repo.search.impl.querymodel.Order; -import org.alfresco.repo.search.impl.querymodel.QueryModelException; -import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.ContentData; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.MLText; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.cmr.repository.datatype.Duration; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.CachingDateFormat; -import org.alfresco.util.ISO9075; -import org.antlr.runtime.ANTLRStringStream; -import org.antlr.runtime.CharStream; -import org.antlr.runtime.CommonTokenStream; -import org.antlr.runtime.RecognitionException; -import org.antlr.runtime.tree.CommonTree; -import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException; -import org.junit.experimental.categories.Category; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * @author andyh - */ -@Category(OwnJVMTestsCategory.class) -public class QueryTest extends BaseCMISTest -{ - private static final String TEST_NAMESPACE = "http://www.alfresco.org/test/cmis-query-test"; - - - - QName typeThatRequiresEncoding = QName.createQName(TEST_NAMESPACE, "type-that-requires-encoding"); - - QName aspectThatRequiresEncoding = QName.createQName(TEST_NAMESPACE, "aspect-that-requires-encoding"); - - QName propertyThatRequiresEncoding = QName.createQName(TEST_NAMESPACE, "property-that-requires-encoding"); - - QName extendedContent = QName.createQName(TEST_NAMESPACE, "extendedContent"); - - QName singleTextBoth = QName.createQName(TEST_NAMESPACE, "singleTextBoth"); - - QName singleTextUntokenised = QName.createQName(TEST_NAMESPACE, "singleTextUntokenised"); - - QName singleTextTokenised = QName.createQName(TEST_NAMESPACE, "singleTextTokenised"); - - QName multipleTextBoth = QName.createQName(TEST_NAMESPACE, "multipleTextBoth"); - - QName multipleTextUntokenised = QName.createQName(TEST_NAMESPACE, "multipleTextUntokenised"); - - QName multipleTextTokenised = QName.createQName(TEST_NAMESPACE, "multipleTextTokenised"); - - QName singleMLTextBoth = QName.createQName(TEST_NAMESPACE, "singleMLTextBoth"); - - QName singleMLTextUntokenised = QName.createQName(TEST_NAMESPACE, "singleMLTextUntokenised"); - - QName singleMLTextTokenised = QName.createQName(TEST_NAMESPACE, "singleMLTextTokenised"); - - QName multipleMLTextBoth = QName.createQName(TEST_NAMESPACE, "multipleMLTextBoth"); - - QName multipleMLTextUntokenised = QName.createQName(TEST_NAMESPACE, "multipleMLTextUntokenised"); - - QName multipleMLTextTokenised = QName.createQName(TEST_NAMESPACE, "multipleMLTextTokenised"); - - QName singleFloat = QName.createQName(TEST_NAMESPACE, "singleFloat"); - - QName multipleFloat = QName.createQName(TEST_NAMESPACE, "multipleFloat"); - - QName singleDouble = QName.createQName(TEST_NAMESPACE, "singleDouble"); - - QName multipleDouble = QName.createQName(TEST_NAMESPACE, "multipleDouble"); - - QName singleInteger = QName.createQName(TEST_NAMESPACE, "singleInteger"); - - QName multipleInteger = QName.createQName(TEST_NAMESPACE, "multipleInteger"); - - QName singleLong = QName.createQName(TEST_NAMESPACE, "singleLong"); - - QName multipleLong = QName.createQName(TEST_NAMESPACE, "multipleLong"); - - QName singleBoolean = QName.createQName(TEST_NAMESPACE, "singleBoolean"); - - QName multipleBoolean = QName.createQName(TEST_NAMESPACE, "multipleBoolean"); - - QName singleDate = QName.createQName(TEST_NAMESPACE, "singleDate"); - - QName multipleDate = QName.createQName(TEST_NAMESPACE, "multipleDate"); - - QName singleDatetime = QName.createQName(TEST_NAMESPACE, "singleDatetime"); - - QName multipleDatetime = QName.createQName(TEST_NAMESPACE, "multipleDatetime"); - - private int content_only_count; - - private int doc_count = 0; - - private int folder_count = 0; - - private NodeRef f0; - - private NodeRef f1; - - private NodeRef f2; - - private NodeRef f3; - - private NodeRef f4; - - private NodeRef f5; - - private NodeRef f6; - - private NodeRef f7; - - private NodeRef f8; - - private NodeRef f9; - - private NodeRef c0; - - private NodeRef c1; - - private NodeRef c2; - - private NodeRef c3; - - private NodeRef c4; - - private NodeRef c5; - - private NodeRef c6; - - private NodeRef c7; - - private NodeRef c8; - - private NodeRef c9; - - private NodeRef c10; - - private Date date1; - - private Date date2; - - private Date date0; - - private long contentLength0; - - private String contentUrl0; - - private boolean usesDateTimeAnalyser; - - @Override - public void setUp() throws Exception - { - super.setUp(); - - DataTypeDefinition dataType = dictionaryService.getDataType(DataTypeDefinition.DATETIME); - String analyserClassName = dataType.resolveAnalyserClassName(); - usesDateTimeAnalyser = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName()); - - f0 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 0", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f0, ContentModel.PROP_NAME, "Folder 0"); - folder_count++; - - permissionService.setPermission(f0, "cmis", PermissionService.READ, true); - - f1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 1", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f1, ContentModel.PROP_NAME, "Folder 1"); - folder_count++; - - f2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 2", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f2, ContentModel.PROP_NAME, "Folder 2"); - folder_count++; - - f3 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 3", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f3, ContentModel.PROP_NAME, "Folder 3"); - folder_count++; - - f4 = nodeService.createNode(f0, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 4", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f4, ContentModel.PROP_NAME, "Folder 4"); - folder_count++; - - f5 = nodeService.createNode(f0, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 5", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f5, ContentModel.PROP_NAME, "Folder 5"); - folder_count++; - - f6 = nodeService.createNode(f5, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 6", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f6, ContentModel.PROP_NAME, "Folder 6"); - folder_count++; - - f7 = nodeService.createNode(f6, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 7", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f7, ContentModel.PROP_NAME, "Folder 7"); - folder_count++; - - f8 = nodeService.createNode(f7, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 8", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f8, ContentModel.PROP_NAME, "Folder 8"); - folder_count++; - - f9 = nodeService.createNode(f8, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Folder 9", namespaceService), ContentModel.TYPE_FOLDER).getChildRef(); - nodeService.setProperty(f9, ContentModel.PROP_NAME, "Folder 9'"); - folder_count++; - - Map properties0 = new HashMap(); - MLText desc0 = new MLText(); - desc0.addValue(Locale.ENGLISH, "Alfresco tutorial"); - desc0.addValue(Locale.US, "Alfresco tutorial"); - properties0.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties0.put(ContentModel.PROP_DESCRIPTION, desc0); - properties0.put(ContentModel.PROP_TITLE, desc0); - properties0.put(ContentModel.PROP_NAME, "Alfresco Tutorial"); - properties0.put(ContentModel.PROP_CREATED, new Date()); - c0 = nodeService.createNode(f0, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Alfresco Tutorial", namespaceService), ContentModel.TYPE_CONTENT, properties0) - .getChildRef(); - ContentWriter writer0 = contentService.getWriter(c0, ContentModel.PROP_CONTENT, true); - writer0.setEncoding("UTF-8"); - writer0.putContent("The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words; a an and are" - + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: " - + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF"); - contentLength0 = writer0.getSize(); - contentUrl0 = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(c0, ContentModel.PROP_CONTENT)).getContentUrl(); - nodeService.addAspect(c0, ContentModel.ASPECT_TITLED, null); - nodeService.addAspect(c0, ContentModel.ASPECT_OWNABLE, null); - nodeService.setProperty(c0, ContentModel.PROP_OWNER, "andy"); - content_only_count++; - doc_count++; - - Map properties1 = new HashMap(); - MLText desc1 = new MLText(); - desc1.addValue(Locale.ENGLISH, "One"); - desc1.addValue(Locale.US, "One"); - properties1.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties1.put(ContentModel.PROP_DESCRIPTION, desc1); - properties1.put(ContentModel.PROP_TITLE, desc1); - properties1.put(ContentModel.PROP_NAME, "AA%"); - properties1.put(ContentModel.PROP_CREATED, new Date()); - c1 = nodeService.createNode(f1, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "One", namespaceService), ContentModel.TYPE_CONTENT, properties1).getChildRef(); - ContentWriter writer1 = contentService.getWriter(c1, ContentModel.PROP_CONTENT, true); - writer1.setEncoding("UTF-8"); - writer1.putContent("One Zebra Apple"); - nodeService.addAspect(c1, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map properties2 = new HashMap(); - MLText desc2 = new MLText(); - desc2.addValue(Locale.ENGLISH, "Two"); - desc2.addValue(Locale.US, "Two"); - properties2.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties2.put(ContentModel.PROP_DESCRIPTION, desc2); - properties2.put(ContentModel.PROP_TITLE, desc2); - properties2.put(ContentModel.PROP_NAME, "BB_"); - properties2.put(ContentModel.PROP_CREATED, new Date()); - c2 = nodeService.createNode(f2, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Two", namespaceService), ContentModel.TYPE_CONTENT, properties2).getChildRef(); - ContentWriter writer2 = contentService.getWriter(c2, ContentModel.PROP_CONTENT, true); - writer2.setEncoding("UTF-8"); - writer2.putContent("Two Zebra Banana"); - nodeService.addAspect(c2, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - Map properties3 = new HashMap(); - MLText desc3 = new MLText(); - desc3.addValue(Locale.ENGLISH, "Three"); - desc3.addValue(Locale.US, "Three"); - properties3.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties3.put(ContentModel.PROP_DESCRIPTION, desc3); - properties3.put(ContentModel.PROP_TITLE, desc3); - properties3.put(ContentModel.PROP_NAME, "CC\\"); - properties3.put(ContentModel.PROP_CREATED, new Date()); - c3 = nodeService.createNode(f3, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Three", namespaceService), ContentModel.TYPE_CONTENT, properties3).getChildRef(); - ContentWriter writer3 = contentService.getWriter(c3, ContentModel.PROP_CONTENT, true); - writer3.setEncoding("UTF-8"); - writer3.putContent("Three Zebra Clementine"); - nodeService.addAspect(c3, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map properties4 = new HashMap(); - MLText desc4 = new MLText(); - desc4.addValue(Locale.ENGLISH, "Four"); - desc4.addValue(Locale.US, "Four"); - properties4.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties4.put(ContentModel.PROP_DESCRIPTION, desc4); - properties4.put(ContentModel.PROP_TITLE, desc4); - properties4.put(ContentModel.PROP_NAME, "DD\'"); - properties4.put(ContentModel.PROP_CREATED, new Date()); - c4 = nodeService.createNode(f4, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Four", namespaceService), ContentModel.TYPE_CONTENT, properties4).getChildRef(); - ContentWriter writer4 = contentService.getWriter(c4, ContentModel.PROP_CONTENT, true); - writer4.setEncoding("UTF-8"); - writer4.putContent("Four zebra durian"); - nodeService.addAspect(c4, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map properties5 = new HashMap(); - MLText desc5 = new MLText(); - desc5.addValue(Locale.ENGLISH, "Five"); - desc5.addValue(Locale.US, "Five"); - properties5.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties5.put(ContentModel.PROP_DESCRIPTION, desc5); - properties5.put(ContentModel.PROP_TITLE, desc5); - properties5.put(ContentModel.PROP_NAME, "EE.aa"); - properties5.put(ContentModel.PROP_CREATED, new Date()); - - c5 = nodeService.createNode(f5, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Five", namespaceService), ContentModel.TYPE_CONTENT, properties5).getChildRef(); - ContentWriter writer5 = contentService.getWriter(c5, ContentModel.PROP_CONTENT, true); - writer5.setEncoding("UTF-8"); - writer5.putContent("Five zebra Ebury"); - nodeService.addAspect(c5, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map lockProperties = new HashMap(); - lockProperties.put(ContentModel.PROP_EXPIRY_DATE, DefaultTypeConverter.INSTANCE.convert(Date.class, "2012-12-12T12:12:12.012Z")); - lockProperties.put(ContentModel.PROP_LOCK_OWNER, "andy"); - lockProperties.put(ContentModel.PROP_LOCK_TYPE, "WRITE_LOCK"); - - nodeService.addAspect(c5, ContentModel.ASPECT_LOCKABLE, lockProperties); - - Map properties6 = new HashMap(); - MLText desc6 = new MLText(); - desc6.addValue(Locale.ENGLISH, "Six"); - desc6.addValue(Locale.US, "Six"); - properties6.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties6.put(ContentModel.PROP_DESCRIPTION, desc6); - properties6.put(ContentModel.PROP_TITLE, desc6); - properties6.put(ContentModel.PROP_NAME, "FF.EE"); - properties6.put(ContentModel.PROP_CREATED, new Date()); - c6 = nodeService.createNode(f6, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Six", namespaceService), ContentModel.TYPE_CONTENT, properties6).getChildRef(); - ContentWriter writer6 = contentService.getWriter(c6, ContentModel.PROP_CONTENT, true); - writer6.setEncoding("UTF-8"); - writer6.putContent("Six zebra fig"); - nodeService.addAspect(c6, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map properties7 = new HashMap(); - MLText desc7 = new MLText(); - desc7.addValue(Locale.ENGLISH, "Seven"); - desc7.addValue(Locale.US, "Seven"); - properties7.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties7.put(ContentModel.PROP_DESCRIPTION, desc7); - properties7.put(ContentModel.PROP_TITLE, desc7); - properties7.put(ContentModel.PROP_NAME, "GG*GG"); - properties7.put(ContentModel.PROP_CREATED, new Date()); - c7 = nodeService.createNode(f7, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Seven", namespaceService), ContentModel.TYPE_CONTENT, properties7).getChildRef(); - ContentWriter writer7 = contentService.getWriter(c7, ContentModel.PROP_CONTENT, true); - writer7.setEncoding("UTF-8"); - writer7.putContent("Seven zebra grapefruit"); - nodeService.addAspect(c7, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map properties8 = new HashMap(); - MLText desc8 = new MLText(); - desc8.addValue(Locale.ENGLISH, "Eight"); - desc8.addValue(Locale.US, "Eight"); - properties8.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties8.put(ContentModel.PROP_DESCRIPTION, desc8); - properties8.put(ContentModel.PROP_TITLE, desc8); - properties8.put(ContentModel.PROP_NAME, "HH?HH"); - properties8.put(ContentModel.PROP_CREATED, new Date()); - c8 = nodeService.createNode(f8, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Eight", namespaceService), ContentModel.TYPE_CONTENT, properties8).getChildRef(); - ContentWriter writer8 = contentService.getWriter(c8, ContentModel.PROP_CONTENT, true); - writer8.setEncoding("UTF-8"); - writer8.putContent("Eight zebra jackfruit"); - nodeService.addAspect(c8, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - - Map properties9 = new HashMap(); - MLText desc9 = new MLText(); - desc9.addValue(Locale.ENGLISH, "Nine"); - desc9.addValue(Locale.US, "Nine"); - properties9.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties9.put(ContentModel.PROP_DESCRIPTION, desc9); - properties9.put(ContentModel.PROP_TITLE, desc9); - properties9.put(ContentModel.PROP_NAME, "aa"); - properties9.put(ContentModel.PROP_CREATED, new Date()); - c9 = nodeService.createNode(f9, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Nine", namespaceService), ContentModel.TYPE_CONTENT, properties9).getChildRef(); - ContentWriter writer9 = contentService.getWriter(c9, ContentModel.PROP_CONTENT, true); - writer9.setEncoding("UTF-8"); - writer9.putContent("Nine zebra kiwi"); - nodeService.addAspect(c9, ContentModel.ASPECT_TITLED, null); - content_only_count++; - doc_count++; - nodeService.setProperty(c9, ContentModel.PROP_VERSION_LABEL, "label"); - - Map properties10 = new HashMap(); - MLText desc10 = new MLText(); - desc10.addValue(Locale.ENGLISH, "Ten"); - desc10.addValue(Locale.US, "Ten"); - properties10.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); - properties10.put(ContentModel.PROP_DESCRIPTION, desc10); - properties10.put(ContentModel.PROP_TITLE, desc10); - properties10.put(ContentModel.PROP_NAME, "aa-thumb"); - properties10.put(ContentModel.PROP_CREATED, new Date()); - c10 = nodeService.createNode(f9, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Ten", namespaceService), ContentModel.TYPE_DICTIONARY_MODEL, properties10).getChildRef(); - ContentWriter writer10 = contentService.getWriter(c10, ContentModel.PROP_CONTENT, true); - writer10.setEncoding("UTF-8"); - writer10.putContent("Tem zebra kiwi thumb"); - nodeService.addAspect(c10, ContentModel.ASPECT_TITLED, null); - doc_count++; - nodeService.setProperty(c10, ContentModel.PROP_VERSION_LABEL, "label"); - } - - private T testQuery(String query, int size, boolean dump, String returnPropertyName, T returnType, boolean shouldThrow) throws Exception - { - return testQuery(query, size, dump, returnPropertyName, returnType, shouldThrow, CMISQueryMode.CMS_STRICT); - } - - private T testExtendedQuery(String query, int size, boolean dump, String returnPropertyName, T returnType, boolean shouldThrow) throws Exception - { - return testQuery(query, size, dump, returnPropertyName, returnType, shouldThrow, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - } - - @SuppressWarnings("unchecked") - private T testQuery(String query, int size, boolean dump, String returnPropertyName, T returnType, boolean shouldThrow, CMISQueryMode mode) throws Exception - { - CMISResultSet rs = null; - try - { - T returnValue = null; - CMISQueryOptions options = new CMISQueryOptions(query, rootNodeRef.getStoreRef()); - options.setQueryMode(mode); - options.setIncludeInTransactionData(true); - rs = cmisQueryService.query(options); - - for (CMISResultSetRow row : rs) - { - if (row.getIndex() == 0) - { - Serializable sValue = row.getValue(returnPropertyName); - returnValue = (T) DefaultTypeConverter.INSTANCE.convert(returnType.getClass(), sValue); - if (dump) - { - System.out.println(cmisService.getProperties(row.getNodeRef(rs.getMetaData().getSelectorNames()[0]))); - } - } - if (dump) - { - System.out.println("ID =" - + row.getValue("cmis:objectId") + " " + ((returnPropertyName != null) ? (returnPropertyName + "=" + row.getValue(returnPropertyName)) : "") + " Score=" - + row.getScore() + " " + row.getScores()); - } - } - if (size >= 0) - { - assertEquals(size, rs.getLength()); - } - if (shouldThrow) - { - fail(); - } - return returnValue; - } - catch (CMISQueryException e) - { - if (shouldThrow) - { - return null; - } - else - { - throw e; - } - } - catch (QueryModelException e) - { - if (shouldThrow) - { - return null; - } - else - { - throw e; - } - } - catch (FTSQueryException e) - { - if (shouldThrow) - { - return null; - } - else - { - throw e; - } - } - catch (CmisInvalidArgumentException e) - { - if (shouldThrow) - { - return null; - } - else - { - throw e; - } - } - catch (UnsupportedOperationException e) - { - if (shouldThrow) - { - return null; - } - else - { - throw e; - } - } - finally - { - if (rs != null) - { - try - { - rs.close(); - } - finally - { - rs = null; - } - } - } - - } - - public void testEncodingOfTypeAndPropertyNames() - { - addTypeTestDataModel(); - assertNotNull("Type not found by query name "+ISO9075.encodeSQL(typeThatRequiresEncoding.toPrefixString(namespaceService)), cmisDictionaryService.findTypeByQueryName(ISO9075.encodeSQL(typeThatRequiresEncoding.toPrefixString(namespaceService)))); - assertNotNull("Aspect not found by query name "+ISO9075.encodeSQL(aspectThatRequiresEncoding.toPrefixString(namespaceService)), cmisDictionaryService.findTypeByQueryName(ISO9075.encodeSQL(aspectThatRequiresEncoding.toPrefixString(namespaceService)))); - assertNotNull("Prpo not found by query name "+ISO9075.encodeSQL(propertyThatRequiresEncoding.toPrefixString(namespaceService)), cmisDictionaryService.findPropertyByQueryName(ISO9075.encodeSQL(propertyThatRequiresEncoding.toPrefixString(namespaceService)))); - - } - - public void test_ALLOWED_CHILD_OBJECT_TYPES() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:allowedChildObjectTypeIds"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:allowedChildObjectTypeIds"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds = 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds <> 'test'", 10, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds < 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds <= 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds > 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds >= 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds IN ('test')", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds NOT IN ('test')", 10, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds LIKE 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds NOT LIKE 'test'", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds IS NOT NULL", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE cmis:allowedChildObjectTypeIds IS NULL", 10, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE 'test' = ANY cmis:allowedChildObjectTypeIds", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE 'test' <> ANY cmis:allowedChildObjectTypeIds", 10, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE 'test' < ANY cmis:allowedChildObjectTypeIds", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE 'test' <= ANY cmis:allowedChildObjectTypeIds", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE 'test' > ANY cmis:allowedChildObjectTypeIds", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE 'test' >= ANY cmis:allowedChildObjectTypeIds", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE ANY cmis:allowedChildObjectTypeIds IN ('test')", 0, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - testQuery("SELECT cmis:allowedChildObjectTypeIds FROM cmis:Folder WHERE ANY cmis:allowedChildObjectTypeIds NOT IN ('test')", 10, false, "cmis:allowedChildObjectTypeIds", - new String(), true); - } - - public void test_PARENT() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:parentId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:parentId"); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ParentProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:folder where cmis:parentId = '" + f8.toString() + "'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:parentId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals(f8.toString(), value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:parentId"); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ParentProperty); - } - rs.close(); - - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId = '" + rootNodeRef.toString() + "'", 4, false, "cmis:parentId", new String(), false); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId <> '" + rootNodeRef.toString() + "'", 6, false, "cmis:parentId", new String(), false); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId < '" + rootNodeRef.toString() + "'", 0, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId <= '" + rootNodeRef.toString() + "'", 0, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId > '" + rootNodeRef.toString() + "'", 0, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId >= '" + rootNodeRef.toString() + "'", 0, false, "cmis:parentId", new String(), true); - - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId IN ('" + rootNodeRef.toString() + "')", 4, false, "cmis:parentId", new String(), false); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId NOT IN ('" + rootNodeRef.toString() + "')", 6, false, "cmis:parentId", new String(), false); - - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId LIKE '" + rootNodeRef.toString() + "'", 4, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId NOT LIKE '" + rootNodeRef.toString() + "'", 6, false, "cmis:parentId", new String(), true); - - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId IS NOT NULL", 10, false, "cmis:parentId", new String(), false); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE cmis:parentId IS NULL", 0, false, "cmis:parentId", new String(), false); - - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE '" + rootNodeRef.toString() + "' = ANY cmis:parentId", 4, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE '" + rootNodeRef.toString() + "' <> ANY cmis:parentId", 6, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE '" + rootNodeRef.toString() + "' < ANY cmis:parentId", 0, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE '" + rootNodeRef.toString() + "' <= ANY cmis:parentId", 0, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE '" + rootNodeRef.toString() + "' > ANY cmis:parentId", 0, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE '" + rootNodeRef.toString() + "' >= ANY cmis:parentId", 0, false, "cmis:parentId", new String(), true); - - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE ANY cmis:parentId IN ('" + rootNodeRef.toString() + "')", 4, false, "cmis:parentId", new String(), true); - testQuery("SELECT cmis:parentId FROM cmis:folder WHERE ANY cmis:parentId NOT IN ('" + rootNodeRef.toString() + "')", 6, false, "cmis:parentId", new String(), true); - } - - public void test_PATH() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:path"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:path"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof PathProperty); - } - rs.close(); - - testQuery("SELECT cmis:path FROM cmis:folder", folder_count, false, "cmis:path", new String(), false); - testQuery("SELECT cmis:path FROM cmis:folder WHERE cmis:path = 'anything'", folder_count, false, "cmis:path", new String(), true); - - } - - public void test_CONTENT_STREAM_ID() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - ContentData cd = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_CONTENT)); - assertEquals(cd.getContentUrl(), value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ContentStreamIdProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:contentStreamFileName = 'Alfresco Tutorial'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals(contentUrl0, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ContentStreamIdProperty); - } - rs.close(); - - testQuery("SELECT cmis:contentStreamId FROM cmis:document", doc_count, false, "cmis:contentStreamId", new String(), false); - - // not allowed in predicates - testQuery("SELECT cmis:contentStreamId FROM cmis:document WHERE cmis:contentStreamId = '" + contentUrl0 + "'", 1, false, "cmis:contentStreamId", new String(), true); - - } - - public void test_CONTENT_STREAM_FILENAME() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamFileName"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamFileName"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:contentStreamFileName = 'Alfresco Tutorial'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamFileName"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("Alfresco Tutorial", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamFileName"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'Alfresco Tutorial'", 1, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'AA%'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'BB_'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'CC\\\\'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'DD\\''", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'EE.aa'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'FF.EE'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'GG*GG'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'HH?HH'", 1, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'aa'", 1, false, "cmis:contentStreamFileName", new String(), false); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName = 'Alfresco Tutorial'", 1, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName <> 'Alfresco Tutorial'", 10, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName < 'Alfresco Tutorial'", 1, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName <= 'Alfresco Tutorial'", 2, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName > 'Alfresco Tutorial'", 9, true, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName >= 'Alfresco Tutorial'", 10, false, "cmis:contentStreamFileName", - new String(), false); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName IN ('Alfresco Tutorial')", 1, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName NOT IN ('Alfresco Tutorial')", 10, false, "cmis:contentStreamFileName", - new String(), false); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName LIKE 'Alfresco Tutorial'", 1, false, "cmis:contentStreamFileName", - new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName NOT LIKE 'Alfresco Tutorial'", 10, false, "cmis:contentStreamFileName", - new String(), false); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName IS NOT NULL", 11, false, "cmis:contentStreamFileName", new String(), false); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE cmis:contentStreamFileName IS NULL", 0, false, "cmis:contentStreamFileName", new String(), false); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE 'Alfresco Tutorial' = ANY cmis:contentStreamFileName", 1, false, "cmis:contentStreamFileName", - new String(), true); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE 'Alfresco Tutorial' <> ANY cmis:contentStreamFileName", 11, false, "cmis:contentStreamFileName", - new String(), true); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE 'Alfresco Tutorial' < ANY cmis:contentStreamFileName", 1, false, "cmis:contentStreamFileName", - new String(), true); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE 'Alfresco Tutorial' <= ANY cmis:contentStreamFileName", 2, false, "cmis:contentStreamFileName", - new String(), true); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE 'Alfresco Tutorial' > ANY cmis:contentStreamFileName", 9, false, "cmis:contentStreamFileName", - new String(), true); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE 'Alfresco Tutorial' >= ANY cmis:contentStreamFileName", 11, false, "cmis:contentStreamFileName", - new String(), true); - - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE ANY cmis:contentStreamFileName IN ('Alfresco Tutorial')", 1, false, "cmis:contentStreamFileName", - new String(), true); - testQuery("SELECT cmis:contentStreamFileName FROM cmis:document WHERE ANY cmis:contentStreamFileName NOT IN ('Alfresco Tutorial')", 10, false, "cmis:contentStreamFileName", - new String(), true); - } - - public void test_CONTENT_STREAM_MIME_TYPE() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamMimeType"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamMimeType"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ContentStreamMimetypeProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:contentStreamMimeType = 'text/plain'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertTrue(rs.length() > 0); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamMimeType"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("text/plain", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamMimeType"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ContentStreamMimetypeProperty); - } - rs.close(); - - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType = 'text/plain'", doc_count, false, "cmis:contentStreamMimeType", new String(), - false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType <> 'text/plain'", 0, false, "cmis:contentStreamMimeType", new String(), - false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType < 'text/plain'", 0, true, "cmis:contentStreamMimeType", new String(), - false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType <= 'text/plain'", doc_count, false, "cmis:contentStreamMimeType", new String(), - false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType > 'text/plain'", 0, false, "cmis:contentStreamMimeType", new String(), - false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType >= 'text/plain'", doc_count, false, "cmis:contentStreamMimeType", new String(), - false); - - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType IN ('text/plain')", doc_count, false, "cmis:contentStreamMimeType", - new String(), false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType NOT IN ('text/plain')", 0, false, "cmis:contentStreamMimeType", - new String(), false); - - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType LIKE 'text/plain'", doc_count, false, "cmis:contentStreamMimeType", - new String(), false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType NOT LIKE 'text/plain'", 0, false, "cmis:contentStreamMimeType", - new String(), false); - - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType IS NOT NULL", doc_count, false, "cmis:contentStreamMimeType", new String(), false); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE cmis:contentStreamMimeType IS NULL", 0, false, "cmis:contentStreamMimeType", new String(), false); - - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE 'text/plain' = ANY cmis:contentStreamMimeType", doc_count, false, "cmis:contentStreamMimeType", - new String(), true); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE 'text/plain' <> ANY cmis:contentStreamMimeType", 0, false, "cmis:contentStreamMimeType", - new String(), true); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE 'text/plain' < ANY cmis:contentStreamMimeType", 0, false, "cmis:contentStreamMimeType", - new String(), true); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE 'text/plain' <= ANY cmis:contentStreamMimeType", doc_count, false, "cmis:contentStreamMimeType", - new String(), true); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE 'text/plain' > ANY cmis:contentStreamMimeType", 0, false, "cmis:contentStreamMimeType", - new String(), true); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE 'text/plain' >= ANY cmis:contentStreamMimeType", doc_count, false, "cmis:contentStreamMimeType", - new String(), true); - - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE ANY cmis:contentStreamMimeType IN ('text/plain')", doc_count, false, "cmis:contentStreamMimeType", - new String(), true); - testQuery("SELECT cmis:contentStreamMimeType FROM cmis:document WHERE ANY cmis:contentStreamMimeType NOT IN ('text/plain')", 0, false, "cmis:contentStreamMimeType", - new String(), true); - } - - public void test_CONTENT_STREAM_LENGTH() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamLength"); - Long value = DefaultTypeConverter.INSTANCE.convert(Long.class, sValue); - assertNotNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamLength"); - assertEquals(CMISDataTypeEnum.INTEGER, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ContentStreamLengthProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:contentStreamLength = " + contentLength0, rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:contentStreamLength"); - Long value = DefaultTypeConverter.INSTANCE.convert(Long.class, sValue); - assertNotNull(value); - assertEquals(Long.valueOf(contentLength0), value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:contentStreamLength"); - assertEquals(CMISDataTypeEnum.INTEGER, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ContentStreamLengthProperty); - } - rs.close(); - - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength = 750", 0, false, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength <> 750", doc_count, true, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength < 750", doc_count, false, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength <= 750", doc_count, false, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength > 750", 0, false, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength >= 750", 0, false, "cmis:contentStreamLength", new String(), false); - - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength IN (750)", 0, false, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength NOT IN (750)", doc_count, false, "cmis:contentStreamLength", new String(), false); - - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength LIKE '750'", 0, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength NOT LIKE '750'", doc_count, false, "cmis:contentStreamLength", new String(), true); - - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength IS NOT NULL", doc_count, false, "cmis:contentStreamLength", new String(), false); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE cmis:contentStreamLength IS NULL", 0, false, "cmis:contentStreamLength", new String(), false); - - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE 750 = ANY cmis:contentStreamLength", 0, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE 750 <> ANY cmis:contentStreamLength", doc_count, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE 750 < ANY cmis:contentStreamLength", doc_count, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE 750 <= ANY cmis:contentStreamLength", doc_count, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE 750 > ANY cmis:contentStreamLength", 0, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE 750 >= ANY cmis:contentStreamLength", 0, false, "cmis:contentStreamLength", new String(), true); - - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE ANY cmis:contentStreamLength IN (750)", 0, false, "cmis:contentStreamLength", new String(), true); - testQuery("SELECT cmis:contentStreamLength FROM cmis:document WHERE ANY cmis:contentStreamLength NOT IN (750)", doc_count, false, "cmis:contentStreamLength", new String(), true); - } - - public void test_CHECKIN_COMMENT() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:checkinComment"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:checkinComment"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof CheckinCommentProperty); - } - rs.close(); - - testQuery("SELECT cmis:checkinComment FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment = 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment <> 'admin'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment < 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment <= 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment > 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment >= 'admin'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment IN ('admin')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment NOT IN ('admin')", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment LIKE 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment NOT LIKE 'admin'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE cmis:checkinComment IS NULL", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE 'admin' = ANY cmis:checkinComment", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE 'admin' <> ANY cmis:checkinComment", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE 'admin' < ANY cmis:checkinComment", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE 'admin' <= ANY cmis:checkinComment", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE 'admin' > ANY cmis:checkinComment", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE 'admin' >= ANY cmis:checkinComment", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE ANY cmis:checkinComment IN ('admin')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:checkinComment FROM cmis:document WHERE ANY cmis:checkinComment NOT IN ('admin')", doc_count, false, "cmis:objectId", new String(), true); - } - - public void test_VERSION_SERIES_CHECKED_OUT_ID() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:versionSeriesCheckedOutId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:versionSeriesCheckedOutId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof VersionSeriesCheckedOutIdProperty); - } - rs.close(); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId = 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId <> 'admin'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId < 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId <= 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId > 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId >= 'admin'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId IN ('admin')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId NOT IN ('admin')", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId LIKE 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId NOT LIKE 'admin'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE cmis:versionSeriesCheckedOutId IS NULL", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE 'admin' = ANY cmis:versionSeriesCheckedOutId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE 'admin' <> ANY cmis:versionSeriesCheckedOutId", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE 'admin' < ANY cmis:versionSeriesCheckedOutId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE 'admin' <= ANY cmis:versionSeriesCheckedOutId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE 'admin' > ANY cmis:versionSeriesCheckedOutId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE 'admin' >= ANY cmis:versionSeriesCheckedOutId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE ANY cmis:versionSeriesCheckedOutId IN ('admin')", 0, false, "cmis:objectId", new String(), - true); - testQuery("SELECT cmis:versionSeriesCheckedOutId FROM cmis:document WHERE ANY cmis:versionSeriesCheckedOutId NOT IN ('admin')", doc_count, false, "cmis:objectId", new String(), - true); - } - - public void test_VERSION_SERIES_CHECKED_OUT_BY() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:versionSeriesCheckedOutBy"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:versionSeriesCheckedOutBy"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof VersionSeriesCheckedOutByProperty); - } - rs.close(); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy = 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy <> 'admin'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy < 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy <= 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy > 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy >= 'admin'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy IN ('admin')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy NOT IN ('admin')", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy LIKE 'admin'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy NOT LIKE 'admin'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE cmis:versionSeriesCheckedOutBy IS NULL", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE 'admin' = ANY cmis:versionSeriesCheckedOutBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE 'admin' <> ANY cmis:versionSeriesCheckedOutBy", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE 'admin' < ANY cmis:versionSeriesCheckedOutBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE 'admin' <= ANY cmis:versionSeriesCheckedOutBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE 'admin' > ANY cmis:versionSeriesCheckedOutBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE 'admin' >= ANY cmis:versionSeriesCheckedOutBy", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE ANY cmis:versionSeriesCheckedOutBy IN ('admin')", 0, false, "cmis:objectId", new String(), - true); - testQuery("SELECT cmis:versionSeriesCheckedOutBy FROM cmis:document WHERE ANY cmis:versionSeriesCheckedOutBy NOT IN ('admin')", doc_count, false, "cmis:objectId", new String(), - true); - } - - public void test_IS_VERSION_SERIES_CHECKED_OUT() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:isVersionSeriesCheckedOut"); - Boolean value = DefaultTypeConverter.INSTANCE.convert(Boolean.class, sValue); - assertNotNull(value); - assertEquals(Boolean.FALSE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:isVersionSeriesCheckedOut"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof IsVersionSeriesCheckedOutProperty); - } - rs.close(); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut = 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut <> 'TRUE'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut < 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut <= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut > 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut >= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut NOT IN ('TRUE')", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut NOT LIKE 'TRUE'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE cmis:isVeriesSeriesCheckedOut IS NULL", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE 'TRUE' = ANY cmis:isVeriesSeriesCheckedOut", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE 'TRUE' <> ANY cmis:isVeriesSeriesCheckedOut", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE 'TRUE' < ANY cmis:isVeriesSeriesCheckedOut", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE 'TRUE' <= ANY cmis:isVeriesSeriesCheckedOut", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE 'TRUE' > ANY cmis:isVeriesSeriesCheckedOut", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE 'TRUE' >= ANY cmis:isVeriesSeriesCheckedOut", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE ANY cmis:isVeriesSeriesCheckedOut IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isVersionSeriesCheckedOut FROM cmis:document WHERE ANY cmis:isVeriesSeriesCheckedOut NOT IN ('TRUE')", doc_count, false, "cmis:objectId", new String(), true); - } - - public void test_VERSION_SERIES_ID() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:versionSeriesId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals(row.getNodeRef().toString(), value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:versionSeriesId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof VersionSeriesIdProperty); - } - rs.close(); - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId = 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId <> 'company'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId < 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId <= 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId > 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId >= 'company'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId IN ('company')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId NOT IN ('company')", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId LIKE 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId NOT LIKE 'company'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE cmis:versionSeriesId IS NULL", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE 'company' = ANY cmis:versionSeriesId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE 'company' <> ANY cmis:versionSeriesId", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE 'company' < ANY cmis:versionSeriesId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE 'company' <= ANY cmis:versionSeriesId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE 'company' > ANY cmis:versionSeriesId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE 'company' >= ANY cmis:versionSeriesId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE ANY cmis:versionSeriesId IN ('company')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionSeriesId FROM cmis:document WHERE ANY cmis:versionSeriesId NOT IN ('company')", doc_count, false, "cmis:objectId", new String(), true); - } - - public void test_VERSION_LABEL() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:versionLabel"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:versionLabel"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof VersionLabelProperty); - } - rs.close(); - - testQuery("SELECT cmis:versionLabel FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel = 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel <> 'company'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel < 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel <= 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel > 'company'", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel >= 'company'", 1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel IN ('company')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel NOT IN ('company')", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel LIKE 'company'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel NOT LIKE 'company'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel IS NOT NULL", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE cmis:versionLabel IS NULL", doc_count-1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE 'company' = ANY cmis:versionLabel", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE 'company' <> ANY cmis:versionLabel", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE 'company' < ANY cmis:versionLabel", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE 'company' <= ANY cmis:versionLabel", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE 'company' > ANY cmis:versionLabel", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE 'company' >= ANY cmis:versionLabel", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE ANY cmis:versionLabel IN ('company')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:versionLabel FROM cmis:document WHERE ANY cmis:versionLabel NOT IN ('company')", doc_count, false, "cmis:objectId", new String(), true); - } - - public void test_IS_LATEST_MAJOR_VERSION() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:isLatestMajorVersion"); - Boolean value = DefaultTypeConverter.INSTANCE.convert(Boolean.class, sValue); - assertNotNull(value); - assertEquals(Boolean.FALSE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:isLatestMajorVersion"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof IsLatestMajorVersionProperty); - } - rs.close(); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion = 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion <> 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion < 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion <= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion > 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion >= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion NOT LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE cmis:isLatestMajorVersion IS NULL", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE 'TRUE' = ANY cmis:isLatestMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE 'TRUE' <> ANY cmis:isLatestMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE 'TRUE' < ANY cmis:isLatestMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE 'TRUE' <= ANY cmis:isLatestMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE 'TRUE' > ANY cmis:isLatestMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE 'TRUE' >= ANY cmis:isLatestMajorVersion", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE ANY cmis:isLatestMajorVersion IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestMajorVersion FROM cmis:document WHERE ANY cmis:isLatestMajorVersion NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - } - - public void test_IS_MAJOR_VERSION() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:isMajorVersion"); - Boolean value = DefaultTypeConverter.INSTANCE.convert(Boolean.class, sValue); - assertNotNull(value); - assertEquals(Boolean.FALSE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:isMajorVersion"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof IsMajorVersionProperty); - } - rs.close(); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion = TRUE", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion = true", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion = FALSE", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion = false", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion <> 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion < 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion <= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion > 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion >= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion NOT LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE cmis:isMajorVersion IS NULL", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE 'TRUE' = ANY cmis:isMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE 'TRUE' <> ANY cmis:isMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE 'TRUE' < ANY cmis:isMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE 'TRUE' <= ANY cmis:isMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE 'TRUE' > ANY cmis:isMajorVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE 'TRUE' >= ANY cmis:isMajorVersion", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE ANY cmis:isMajorVersion IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isMajorVersion FROM cmis:document WHERE ANY cmis:isMajorVersion NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - } - - public void test_IS_LATEST_VERSION() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:isLatestVersion"); - Boolean value = DefaultTypeConverter.INSTANCE.convert(Boolean.class, sValue); - assertNotNull(value); - assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:isLatestVersion"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof IsLatestVersionProperty); - } - rs.close(); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion = 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion <> 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion < 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion <= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion > 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion >= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion NOT LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE cmis:isLatestVersion IS NULL", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE 'TRUE' = ANY cmis:isLatestVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE 'TRUE' <> ANY cmis:isLatestVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE 'TRUE' < ANY cmis:isLatestVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE 'TRUE' <= ANY cmis:isLatestVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE 'TRUE' > ANY cmis:isLatestVersion", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE 'TRUE' >= ANY cmis:isLatestVersion", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE ANY cmis:isLatestVersion IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isLatestVersion FROM cmis:document WHERE ANY cmis:isLatestVersion NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - } - - public void test_IS_IMMUTABLE() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:Document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:isImmutable"); - Boolean value = DefaultTypeConverter.INSTANCE.convert(Boolean.class, sValue); - assertNotNull(value); - assertEquals(Boolean.FALSE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:isImmutable"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof IsImmutableProperty); - } - rs.close(); - - testQuery("SELECT cmis:isImmutable FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable = 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable <> 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable < 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable <= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable > 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable >= 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable NOT LIKE 'TRUE'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE cmis:isImmutable IS NULL", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE 'TRUE' = ANY cmis:isImmutable", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE 'TRUE' <> ANY cmis:isImmutable", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE 'TRUE' < ANY cmis:isImmutable", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE 'TRUE' <= ANY cmis:isImmutable", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE 'TRUE' > ANY cmis:isImmutable", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE 'TRUE' >= ANY cmis:isImmutable", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE ANY cmis:isImmutable IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:isImmutable FROM cmis:document WHERE ANY cmis:isImmutable NOT IN ('TRUE')", 0, false, "cmis:objectId", new String(), true); - } - - public void test_folder_NAME() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:name"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:name"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:folder WHERE cmis:name = 'Folder 1'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:name"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("Folder 1", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:name"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name = 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name <> 'Folder 1'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name < 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name <= 'Folder 1'", 2, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name > 'Folder 1'", 8, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name >= 'Folder 1'", 9, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name IN ('Folder 1')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name NOT IN ('Folder 1')", 9, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name LIKE 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name NOT LIKE 'Folder 1'", 9, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name IS NOT NULL", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:name FROM cmis:folder WHERE cmis:name IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:folder WHERE 'Folder 1' = ANY cmis:name", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:name FROM cmis:folder WHERE 'Folder 1' <> ANY cmis:name", 9, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:name FROM cmis:folder WHERE 'Folder 1' < ANY cmis:name", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:name FROM cmis:folder WHERE 'Folder 1' <= ANY cmis:name", 2, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:name FROM cmis:folder WHERE 'Folder 1' > ANY cmis:name", 8, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:name FROM cmis:folder WHERE 'Folder 1' >= ANY cmis:name", 9, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:name FROM cmis:folder WHERE ANY cmis:name IN ('Folder 1')", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:name FROM cmis:folder WHERE ANY cmis:name NOT IN ('Folder 1')", 9, false, "cmis:objectId", new String(), true); - } - - public void test_document_Name() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:name"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:name"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:name = 'Alfresco Tutorial'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:name"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("Alfresco Tutorial", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:name"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name = 'Alfresco Tutorial'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name <> 'Alfresco Tutorial'", doc_count-1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name < 'Alfresco Tutorial'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name <= 'Alfresco Tutorial'", 2, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name > 'Alfresco Tutorial'", doc_count-2, true, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name >= 'Alfresco Tutorial'", doc_count-1, false, "cmis:name", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name IN ('Alfresco Tutorial')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name NOT IN ('Alfresco Tutorial')", doc_count-1, false, "cmis:name", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco Tutorial'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name NOT LIKE 'Alfresco Tutorial'", doc_count-1, false, "cmis:name", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name IS NOT NULL", doc_count, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name IS NULL", 0, false, "cmis:name", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:document WHERE 'Alfresco Tutorial' = ANY cmis:name", 1, false, "cmis:name", new String(), true); - testQuery("SELECT cmis:name FROM cmis:document WHERE 'Alfresco Tutorial' <> ANY cmis:name", doc_count-1, false, "cmis:name", new String(), true); - testQuery("SELECT cmis:name FROM cmis:document WHERE 'Alfresco Tutorial' < ANY cmis:name", 1, false, "cmis:name", new String(), true); - testQuery("SELECT cmis:name FROM cmis:document WHERE 'Alfresco Tutorial' <= ANY cmis:name", 2, false, "cmis:name", new String(), true); - testQuery("SELECT cmis:name FROM cmis:document WHERE 'Alfresco Tutorial' > ANY cmis:name", doc_count-2, false, "cmis:name", new String(), true); - testQuery("SELECT cmis:name FROM cmis:document WHERE 'Alfresco Tutorial' >= ANY cmis:name", doc_count-1, false, "cmis:name", new String(), true); - - testQuery("SELECT cmis:name FROM cmis:document WHERE ANY cmis:name IN ('Alfresco Tutorial')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT cmis:name FROM cmis:document WHERE ANY cmis:name NOT IN ('Alfresco Tutorial')", doc_count-1, false, "cmis:name", new String(), true); - } - - public void test_CHANGE_TOKEN() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:changeToken"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNull(value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:changeToken"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof FixedValueProperty); - } - rs.close(); - - testQuery("SELECT cmis:changeToken FROM cmis:folder", 10, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken = 'test'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken <> 'test'", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken < 'test'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken <= 'test'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken > 'test'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken >= 'test'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken IN ('test')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken NOT IN ('test')", 10, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken LIKE 'test'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken NOT LIKE 'test'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken IS NOT NULL", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE cmis:changeToken IS NULL", 10, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE 'test' = ANY cmis:changeToken", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE 'test' <> ANY cmis:changeToken", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE 'test' < ANY cmis:changeToken", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE 'test' <= ANY cmis:changeToken", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE 'test' > ANY cmis:changeToken", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE 'test' >= ANY cmis:changeToken", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE ANY cmis:changeToken IN ('test')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:changeToken FROM cmis:folder WHERE ANY cmis:changeToken NOT IN ('test')", 10, false, "cmis:objectId", new String(), true); - } - - public void test_LAST_MODIFICATION_DATE() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:lastModificationDate"); - Date value = DefaultTypeConverter.INSTANCE.convert(Date.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:lastModificationDate"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - // By default we are only working to the day - - Calendar today = Calendar.getInstance(); - - if ((today.get(Calendar.HOUR_OF_DAY) == 0) || (today.get(Calendar.HOUR_OF_DAY) == 23)) - { - return; - } - - SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", true); - - Date lmd0 = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(c0, ContentModel.PROP_MODIFIED)); - String lmds0 = df.format(lmd0); - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:lastModificationDate = TIMESTAMP '" + lmds0 + "' and cmis:objectId = '" + c0.toString() + "'", - rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:lastModificationDate"); - Date value = DefaultTypeConverter.INSTANCE.convert(Date.class, sValue); - assertNotNull(value); - assertEquals(lmd0, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:lastModificationDate"); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - Date date = testQuery("SELECT cmis:lastModificationDate FROM cmis:document", -1, false, "cmis:lastModificationDate", new Date(), false); - today.setTime(date); - if(!usesDateTimeAnalyser) - { - today.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - } - - String sDate = df.format(today.getTime()); - String sDate2 = sDate.substring(0, sDate.length() - 1) + "+00:00"; - - // Today (assuming al ws created today) - - if(usesDateTimeAnalyser) - { - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = TIMESTAMP '" + sDate + "'", 1, false, "cmis:objectId", new String(), - false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = TIMESTAMP '" + sDate2 + "'", 1, false, "cmis:objectId", new String(), - false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <> '" + sDate + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate < '" + sDate + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate >= '" + sDate + "'", 1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IN ('" + sDate + "')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count-1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate LIKE '" + sDate + "'", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT LIKE '" + sDate + "'", doc_count-1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:lastModificationDate", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:lastModificationDate", doc_count-1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:lastModificationDate", doc_count-1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:lastModificationDate", 1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate IN ('" + sDate + "')", 1, false, "cmis:objectId", new String(), - true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count-1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "') order by cmis:lastModificationDate", doc_count-1, false, - "cmis:objectId", new String(), true); - - // using yesterday - - date = Duration.subtract(date, new Duration("P1D")); - Calendar yesterday = Calendar.getInstance(); - yesterday.setTime(date); - yesterday.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(yesterday.getTime()); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate < '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate > '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate >= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), - true); - - // using tomorrow - - date = Duration.add(date, new Duration("P2D")); - Calendar tomorrow = Calendar.getInstance(); - tomorrow.setTime(date); - tomorrow.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(tomorrow.getTime()); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate < '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate >= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), - true); - } - else - { - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = TIMESTAMP '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), - false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = TIMESTAMP '" + sDate2 + "'", doc_count, false, "cmis:objectId", new String(), - false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <> '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate < '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate >= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), - true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "') order by cmis:lastModificationDate", 0, false, - "cmis:objectId", new String(), true); - - // using yesterday - - date = Duration.subtract(date, new Duration("P1D")); - Calendar yesterday = Calendar.getInstance(); - yesterday.setTime(date); - yesterday.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(yesterday.getTime()); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate < '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate > '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate >= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), - true); - - // using tomorrow - - date = Duration.add(date, new Duration("P2D")); - Calendar tomorrow = Calendar.getInstance(); - tomorrow.setTime(date); - tomorrow.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(tomorrow.getTime()); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate < '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate >= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE cmis:lastModificationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:lastModificationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:lastModificationDate", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModificationDate FROM cmis:document WHERE ANY cmis:lastModificationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), - true); - } - - - } - - public void test_LAST_MODIFIED_BY() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:lastModifiedBy"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:lastModifiedBy"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:lastModifiedBy = 'System'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:lastModifiedBy"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("System", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:lastModifiedBy"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy = 'System'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy <> 'System'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy < 'System'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy <= 'System'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy > 'System'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy >= 'System'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy IN ('System')", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy NOT IN ('System')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy LIKE 'System'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy NOT LIKE 'System'", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE cmis:lastModifiedBy IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE 'System' = ANY cmis:lastModifiedBy", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE 'System' <> ANY cmis:lastModifiedBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE 'System' < ANY cmis:lastModifiedBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE 'System' <= ANY cmis:lastModifiedBy", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE 'System' > ANY cmis:lastModifiedBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE 'System' >= ANY cmis:lastModifiedBy", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE ANY cmis:lastModifiedBy IN ('System')", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE ANY cmis:lastModifiedBy NOT IN ('System')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:lastModifiedBy FROM cmis:document WHERE ANY cmis:lastModifiedBy NOT IN ('System') order by cmis:lastModifiedBy", 0, true, "cmis:objectId", - new String(), true); - } - - public void test_CREATION_DATE() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:creationDate"); - Date value = DefaultTypeConverter.INSTANCE.convert(Date.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:creationDate"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - // By default we are only working to the day - - Calendar today = Calendar.getInstance(); - - if ((today.get(Calendar.HOUR_OF_DAY) == 0) || (today.get(Calendar.HOUR_OF_DAY) == 23)) - { - return; - } - - SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", true); - - Date cd0 = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(c0, ContentModel.PROP_CREATED)); - String cds0 = df.format(cd0); - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:creationDate = TIMESTAMP '" + cds0 + "' and cmis:objectId = '" + c0.toString() + "'", rootNodeRef - .getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:creationDate"); - Date value = DefaultTypeConverter.INSTANCE.convert(Date.class, sValue); - assertNotNull(value); - assertEquals(cd0, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:creationDate"); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - Date date = testQuery("SELECT cmis:creationDate FROM cmis:document", -1, false, "cmis:creationDate", new Date(), false); - today.setTime(date); - - // start.set(Calendar.YEAR, start.getMinimum(Calendar.YEAR)); - // start.set(Calendar.DAY_OF_YEAR, start.getMinimum(Calendar.DAY_OF_YEAR)); - // start.set(Calendar.HOUR_OF_DAY, start.getMinimum(Calendar.HOUR_OF_DAY)); - // start.set(Calendar.MINUTE, start.getMinimum(Calendar.MINUTE)); - // start.set(Calendar.SECOND, start.getMinimum(Calendar.SECOND)); - if(!usesDateTimeAnalyser) - { - today.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - } - - String sDate = df.format(today.getTime()); - - // Today (assuming al ws created today) - - if(usesDateTimeAnalyser) - { - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate = '" + sDate + "'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <> '" + sDate + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate < '" + sDate + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate >= '" + sDate + "'", 1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IN ('" + sDate + "')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT IN ('" + sDate + "')", doc_count-1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate LIKE '" + sDate + "'", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT LIKE '" + sDate + "'", doc_count-1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:creationDate", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:creationDate", doc_count-1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:creationDate", doc_count-1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:creationDate", 1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate IN ('" + sDate + "')", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "')", doc_count-1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "') order by cmis:creationDate", doc_count-1, false, "cmis:objectId", - new String(), true); - - // using yesterday - - date = Duration.subtract(date, new Duration("P1D")); - Calendar yesterday = Calendar.getInstance(); - yesterday.setTime(date); - yesterday.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(yesterday.getTime()); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate < '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate > '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate >= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), true); - - // using tomorrow - - date = Duration.add(date, new Duration("P2D")); - Calendar tomorrow = Calendar.getInstance(); - tomorrow.setTime(date); - tomorrow.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(tomorrow.getTime()); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate < '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate >= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), true); - } - else - { - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate = '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <> '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate < '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate >= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "') order by cmis:creationDate", 0, false, "cmis:objectId", - new String(), true); - - // using yesterday - - date = Duration.subtract(date, new Duration("P1D")); - Calendar yesterday = Calendar.getInstance(); - yesterday.setTime(date); - yesterday.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(yesterday.getTime()); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate < '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate > '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate >= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), true); - - // using tomorrow - - date = Duration.add(date, new Duration("P2D")); - Calendar tomorrow = Calendar.getInstance(); - tomorrow.setTime(date); - tomorrow.set(Calendar.MILLISECOND, today.getMinimum(Calendar.MILLISECOND)); - sDate = df.format(tomorrow.getTime()); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate = '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <> '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate < '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate <= '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate > '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate >= '" + sDate + "'", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate LIKE '" + sDate + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate NOT LIKE '" + sDate + "'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE cmis:creationDate IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' = ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <> ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' < ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' <= ANY cmis:creationDate", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' > ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE '" + sDate + "' >= ANY cmis:creationDate", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate IN ('" + sDate + "')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:creationDate FROM cmis:document WHERE ANY cmis:creationDate NOT IN ('" + sDate + "')", doc_count, false, "cmis:objectId", new String(), true); - - } - - } - - public void test_CREATED_BY() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:createdBy"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:createdBy"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document WHERE cmis:createdBy = 'System'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:createdBy"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("System", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:createdBy"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof DirectProperty); - } - rs.close(); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy = 'System'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy <> 'System'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy < 'System'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy <= 'System'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy > 'System'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy >= 'System'", doc_count, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy IN ('System')", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy NOT IN ('System')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy LIKE 'System'", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy NOT LIKE 'System'", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE cmis:createdBy IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE 'System' = ANY cmis:createdBy", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE 'System' <> ANY cmis:createdBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE 'System' < ANY cmis:createdBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE 'System' <= ANY cmis:createdBy", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE 'System' > ANY cmis:createdBy", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE 'System' >= ANY cmis:createdBy", doc_count, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE ANY cmis:createdBy IN ('System')", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE ANY cmis:createdBy NOT IN ('System')", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:createdBy FROM cmis:document WHERE ANY cmis:createdBy IN ('System') order by cmis:createdBy", doc_count, false, "cmis:objectId", new String(), true); - - } - - public void test_OBJECT_TYPE_ID() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectTypeId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertTrue(value.equals("cmis:document") || value.equals("D:cm:dictionaryModel")); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:objectTypeId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ObjectTypeIdProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectTypeId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("cmis:folder", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:objectTypeId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ObjectTypeIdProperty); - } - rs.close(); - - // DOC - - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId = 'cmis:document'", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId <> 'cmis:document'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId < 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId <= 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId > 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId >= 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId IN ('cmis:document')", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId NOT IN ('cmis:document')", 1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId LIKE 'cmis:document'", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId NOT LIKE 'cmis:document'", 1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE cmis:objectTypeId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE 'cmis:document' = ANY cmis:objectTypeId", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE 'cmis:document' <> ANY cmis:objectTypeId", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE 'cmis:document' < ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE 'cmis:document' <= ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE 'cmis:document' > ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE 'cmis:document' >= ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE ANY cmis:objectTypeId IN ('cmis:document')", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:document WHERE ANY cmis:objectTypeId NOT IN ('cmis:document')", 1, false, "cmis:objectId", new String(), true); - - // FOLDER - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId = 'cmis:folder'", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId <> 'cmis:folder'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId < 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId <= 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId > 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId >= 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId IN ('cmis:folder')", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId NOT IN ('cmis:folder')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId LIKE 'cmis:folder'", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId NOT LIKE 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId IS NOT NULL", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' = ANY cmis:objectTypeId", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' <> ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' < ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' <= ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' > ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' >= ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE ANY cmis:objectTypeId IN ('cmis:folder')", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE ANY cmis:objectTypeId NOT IN ('cmis:folder')", 0, false, "cmis:objectId", new String(), true); - - // RELATIONSHIP - - testQuery("SELECT cmis:objectTypeId FROM Relationship WHERE cmis:objectTypeId = ''", 1, false, "cmis:objectId", new String(), true); - - } - - public void test_BASE_TYPE_ID() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:baseTypeId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("cmis:document", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:baseTypeId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof BaseTypeIdProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:baseTypeId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals("cmis:folder", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:baseTypeId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof BaseTypeIdProperty); - } - rs.close(); - - // DOC - - testQuery("SELECT cmis:baseTypeId FROM cmis:document", doc_count, false, "cmis:baseTypeId", new String(), false); - - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId = 'cmis:document'", doc_count, false, "cmis:baseTypeId", new String(), false); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId <> 'cmis:document'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId < 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId <= 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId > 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId >= 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId IN ('cmis:document')", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId NOT IN ('cmis:document')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId LIKE 'cmis:document'", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId NOT LIKE 'cmis:document'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE 'cmis:document' = ANY cmis:baseTypeId", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE 'cmis:document' <> ANY cmis:baseTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE 'cmis:document' < ANY cmis:baseTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE 'cmis:document' <= ANY cmis:baseTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE 'cmis:document' > ANY cmis:baseTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE 'cmis:document' >= ANY cmis:baseTypeId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE ANY cmis:baseTypeId IN ('cmis:document')", doc_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE ANY cmis:baseTypeId NOT IN ('cmis:document')", 0, false, "cmis:objectId", new String(), true); - - - - - testQuery("SELECT cmis:baseTypeId FROM cmis:folder", folder_count, false, "cmis:baseTypeId", new String(), false); - - testQuery("SELECT cmis:baseTypeId FROM cmis:folder WHERE cmis:baseTypeId = 'cmis:folder'", folder_count, false, "cmis:baseTypeId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId <> 'cmis:folder'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId < 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId <= 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId > 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId >= 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId IN ('cmis:folder')", folder_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId NOT IN ('cmis:folder')", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId LIKE 'cmis:folder'", folder_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId NOT LIKE 'cmis:folder'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId IS NOT NULL", folder_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE cmis:objectTypeId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' = ANY cmis:objectTypeId", folder_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' <> ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' < ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' <= ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' > ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE 'cmis:folder' >= ANY cmis:objectTypeId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE ANY cmis:objectTypeId IN ('cmis:folder')", folder_count, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectTypeId FROM cmis:folder WHERE ANY cmis:objectTypeId NOT IN ('cmis:folder')", 0, false, "cmis:objectId", new String(), true); - - // RELATIONSHIP - - testQuery("SELECT cmis:baseTypeId FROM cmis:relationship WHERE cmis:baseTypeId = 'cmis:relationship'", 1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:baseTypeId FROM cmis:policy WHERE cmis:baseTypeId = 'cmis:relationship'", 1, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:baseTypeId FROM cmis:folder WHERE cmis:baseTypeId = 'cmis:policy'", 0, false, "cmis:baseTypeId", new String(), false); - testQuery("SELECT cmis:baseTypeId FROM cmis:folder WHERE cmis:baseTypeId = 'cmis:relationship'", 0, false, "cmis:baseTypeId", new String(), true); - - testQuery("SELECT cmis:baseTypeId FROM cmis:folder WHERE cmis:baseTypeId = 'cmis:document'", 0, false, "cmis:baseTypeId", new String(), false); - testQuery("SELECT cmis:baseTypeId FROM cmis:document WHERE cmis:baseTypeId = 'cmis:folder'", 0, false, "cmis:baseTypeId", new String(), false); - - } - - public void test_ObjectId() throws Exception - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(doc_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:objectId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ObjectIdProperty); - } - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(folder_count, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - // assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:objectId"); - assertNotNull(column); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ObjectIdProperty); - } - rs.close(); - - String companyHomeId = testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:name = 'Folder 0'", 1, false, "cmis:objectId", new String(), false); - - options = new CMISQueryOptions("SELECT * FROM cmis:folder WHERE cmis:objectId = '" + companyHomeId + "'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectId"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertNotNull(value); - assertEquals(companyHomeId, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("cmis:objectId"); - assertEquals(CMISDataTypeEnum.ID, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - assertTrue(column.getCMISPropertyDefinition().getPropertyAccessor() instanceof ObjectIdProperty); - } - rs.close(); - - Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); - String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser); - - assertEquals(companyHomeId, id); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId = '" + companyHomeId + "'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId <> '" + companyHomeId + "'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId < '" + companyHomeId + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId <= '" + companyHomeId + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId > '" + companyHomeId + "'", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId >= '" + companyHomeId + "'", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId IN ('" + companyHomeId + "')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId NOT IN ('" + companyHomeId + "')", 9, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId LIKE '" + companyHomeId + "'", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId NOT LIKE '" + companyHomeId + "'", 9, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE IN_FOLDER('" + companyHomeId + "')", 2, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE IN_TREE ('" + companyHomeId + "')", 6, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId IS NOT NULL", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE '" + companyHomeId + "' = ANY cmis:objectId", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE '" + companyHomeId + "' <> ANY cmis:objectId", 9, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE '" + companyHomeId + "' < ANY cmis:objectId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE '" + companyHomeId + "' <= ANY cmis:objectId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE '" + companyHomeId + "' > ANY cmis:objectId", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE '" + companyHomeId + "' >= ANY cmis:objectId", 0, false, "cmis:objectId", new String(), true); - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE ANY cmis:objectId IN ('" + companyHomeId + "')", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE ANY cmis:objectId NOT IN ('" + companyHomeId + "')", 9, false, "cmis:objectId", new String(), true); - - // Folder versions which are ignored .... - - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId = '" + companyHomeId + ";1.0'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId <> '" + companyHomeId + ";1.0'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId IN ('" + companyHomeId + ";1.0')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId NOT IN ('" + companyHomeId + ";1.0')", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId IS NOT NULL", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:folder WHERE cmis:objectId IS NULL", 0, false, "cmis:objectId", new String(), false); - - // Docs - - - String docId = testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:name = 'Alfresco Tutorial'", 1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId = '" + docId + "'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId <> '" + docId + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IN ('" + docId + "')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId NOT IN ('" + docId + "')", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId = '" + docId + ";1.0'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId <> '" + docId + ";1.0'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IN ('" + docId + ";1.0')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId NOT IN ('" + docId + ";1.0')", doc_count-1, false, "cmis:objectId", new String(), false); - - nodeService.setProperty(c0, ContentModel.PROP_VERSION_LABEL, "1.0"); - - docId = testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:name = 'Alfresco Tutorial'", 1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId = '" + docId + "'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId <> '" + docId + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IN ('" + docId + "')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId NOT IN ('" + docId + "')", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId = '" + docId + ";1.0'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId <> '" + docId + ";1.0'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IN ('" + docId + ";1.0')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId NOT IN ('" + docId + ";1.0')", doc_count-1, false, "cmis:objectId", new String(), false); - - nodeService.setProperty(c0, ContentModel.PROP_VERSION_LABEL, "2.1"); - - docId = testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:name = 'Alfresco Tutorial'", 1, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId = '" + docId + "'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId <> '" + docId + "'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IN ('" + docId + "')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId NOT IN ('" + docId + "')", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IS NULL", 0, false, "cmis:objectId", new String(), false); - - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId = '" + docId + ";2.1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId <> '" + docId + ";2.1'", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId IN ('" + docId + ";2.1')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT cmis:objectId FROM cmis:document WHERE cmis:objectId NOT IN ('" + docId + ";2.1')", doc_count-1, false, "cmis:objectId", new String(), false); - - } - - public void testOrderBy() throws Exception - { - testOrderBy("SELECT cmis:objectId FROM cmis:folder ORDER BY cmis:objectId", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder ORDER BY cmis:objectTypeId", folder_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectTypeId"); - // testOrderBy("SELECT cmis:objectId FROM cmis:folder ORDER BY cmis:objectTypeId", folder_count, false, - // Order.ASCENDING, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, - // "cmis:objectTypeId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder ORDER BY cmis:objectId ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder ORDER BY cmis:objectId DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder ORDER BY cmis:objectId DESC", folder_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - - testOrderBy("SELECT cmis:objectId Meep FROM cmis:folder ORDER BY Meep", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "Meep"); - testOrderBy("SELECT cmis:objectId Meep FROM cmis:folder ORDER BY cmis:objectId", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "Meep"); - testOrderBy("SELECT cmis:objectId Meep FROM cmis:folder ORDER BY Meep ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "Meep"); - testOrderBy("SELECT cmis:objectId Meep FROM cmis:folder ORDER BY Meep DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "Meep"); - - testOrderBy("SELECT cmis:objectId FROM cmis:folder F ORDER BY F.cmis:objectId", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder F ORDER BY cmis:objectId", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder F ORDER BY F.cmis:objectId ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "F.cmis:objectId"); - testOrderBy("SELECT cmis:objectId FROM cmis:folder F ORDER BY F.cmis:objectId DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "F.cmis:objectId"); - - testOrderBy("SELECT F.cmis:objectId Meep FROM cmis:folder F ORDER BY Meep", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "Meep"); - testOrderBy("SELECT F.cmis:objectId Meep FROM cmis:folder F ORDER BY F.cmis:objectId", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "F.cmis:objectId"); - testOrderBy("SELECT F.cmis:objectId Meep FROM cmis:folder F ORDER BY cmis:objectId", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "F.cmis:objectId"); - testOrderBy("SELECT F.cmis:objectId Meep FROM cmis:folder F ORDER BY Meep ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectId"); - testOrderBy("SELECT F.cmis:objectId Meep FROM cmis:folder F ORDER BY Meep DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "Meep"); - - testOrderBy("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:document where CONTAINS('*') ORDER BY MEEP", doc_count, false, Order.ASCENDING, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, - "MEEP"); - testOrderBy("SELECT SCORE(), cmis:objectId FROM cmis:document where CONTAINS('*') ORDER BY SEARCH_SCORE", doc_count, false, Order.ASCENDING, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, - "SEARCH_SCORE"); - testOrderBy("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:document where CONTAINS('*') ORDER BY MEEP ASC", doc_count, false, Order.ASCENDING, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, - "MEEP"); - testOrderBy("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:document where CONTAINS('*') ORDER BY MEEP DESC", doc_count, false, Order.DESCENDING, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, "MEEP"); - - testOrderBy("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder where CONTAINS('cmis:name:*') ORDER BY MEEP", folder_count, false, Order.ASCENDING, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, "MEEP"); - testOrderBy("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder where CONTAINS('cmis:name:*') ORDER BY MEEP ASC", folder_count, false, Order.ASCENDING, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, "MEEP"); - testOrderBy("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder where CONTAINS('cmis:name:*') ORDER BY MEEP DESC", folder_count, false, Order.DESCENDING, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS, "MEEP"); - - // other orderable properties - - testOrderBy("SELECT cmis:objectTypeId FROM cmis:folder ORDER BY cmis:objectTypeId ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:objectTypeId"); - testOrderBy("SELECT cmis:objectTypeId FROM cmis:folder ORDER BY cmis:objectTypeId DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:objectTypeId"); - // all are equal ... - testOrderBy("SELECT cmis:objectTypeId FROM cmis:folder ORDER BY cmis:objectTypeId ASC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:objectTypeId"); - - testOrderBy("SELECT cmis:createdBy FROM cmis:folder ORDER BY cmis:createdBy ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:createdBy"); - testOrderBy("SELECT cmis:createdBy FROM cmis:folder ORDER BY cmis:createdBy DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "cmis:createdBy"); - // all are equal - testOrderBy("SELECT cmis:createdBy FROM cmis:folder ORDER BY cmis:createdBy ASC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "cmis:createdBy"); - - testOrderBy("SELECT cmis:creationDate FROM cmis:folder ORDER BY cmis:creationDate ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:creationDate"); - testOrderBy("SELECT cmis:creationDate FROM cmis:folder ORDER BY cmis:creationDate DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:creationDate"); - testOrderBy("SELECT cmis:creationDate FROM cmis:folder ORDER BY cmis:creationDate DESC", folder_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:creationDate"); - - testOrderBy("SELECT cmis:lastModifiedBy FROM cmis:folder ORDER BY cmis:lastModifiedBy ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - "cmis:lastModifiedBy"); - testOrderBy("SELECT cmis:lastModifiedBy FROM cmis:folder ORDER BY cmis:lastModifiedBy DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:lastModifiedBy"); - // all equals .. - testOrderBy("SELECT cmis:lastModifiedBy FROM cmis:folder ORDER BY cmis:lastModifiedBy DESC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - "cmis:lastModifiedBy"); - - testOrderBy("SELECT cmis:lastModificationDate FROM cmis:folder ORDER BY cmis:lastModificationDate ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - "cmis:lastModificationDate"); - testOrderBy("SELECT cmis:lastModificationDate FROM cmis:folder ORDER BY cmis:lastModificationDate DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:lastModificationDate"); - testOrderBy("SELECT cmis:lastModificationDate FROM cmis:folder ORDER BY cmis:lastModificationDate DESC", folder_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - "cmis:lastModificationDate"); - - testOrderBy("SELECT cmis:name FROM cmis:folder ORDER BY cmis:name ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:name"); - testOrderBy("SELECT cmis:name FROM cmis:folder ORDER BY cmis:name DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "cmis:name"); - testOrderBy("SELECT cmis:name FROM cmis:folder ORDER BY cmis:name DESC", folder_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:name"); - - testOrderBy("SELECT cmis:name FROM cmis:document ORDER BY cmis:name ASC", doc_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:name"); - testOrderBy("SELECT cmis:name FROM cmis:document ORDER BY cmis:name DESC", doc_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "cmis:name"); - testOrderBy("SELECT cmis:name FROM cmis:document ORDER BY cmis:name DESC", doc_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:name"); - - // version label is not orderable as indexed and tokenised - testOrderBy("SELECT cmis:versionLabel FROM cmis:document ORDER BY cmis:versionLabel ASC", doc_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:versionLabel"); - testOrderBy("SELECT cmis:versionLabel FROM cmis:document ORDER BY cmis:versionLabel DESC", doc_count, true, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:versionLabel"); - testOrderBy("SELECT cmis:versionLabel FROM cmis:document ORDER BY cmis:versionLabel DESC", doc_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:versionLabel"); - - // cmis:contentStreamFileName is not orderable as indexed and tokenised - testOrderBy("SELECT cmis:contentStreamFileName FROM cmis:document ORDER BY cmis:contentStreamFileName ASC", doc_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - "cmis:contentStreamFileName"); - testOrderBy("SELECT cmis:contentStreamFileName FROM cmis:document ORDER BY cmis:contentStreamFileName DESC", doc_count, true, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - "cmis:contentStreamFileName"); - testOrderBy("SELECT cmis:contentStreamFileName FROM cmis:document ORDER BY cmis:contentStreamFileName DESC", doc_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - "cmis:contentStreamFileName"); - - testOrderBy("SELECT cmis:parentId FROM cmis:folder ORDER BY cmis:parentId ASC", folder_count, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:parentId"); - testOrderBy("SELECT cmis:parentId FROM cmis:folder ORDER BY cmis:parentId DESC", folder_count, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, "cmis:parentId"); - testOrderBy("SELECT cmis:parentId FROM cmis:folder ORDER BY cmis:parentId DESC", folder_count, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, "cmis:parentId"); - - testQuery("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder WHERE CONTAINS('cmis:name:*') AND cmis:name = 'compan home' ORDER BY SCORE() DESC", 1, false, - "cmis:objectId", new String(), true); - testQuery("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder WHERE CONTAINS('cmis:name:*') AND cmis:name IN ('company', 'home') ORDER BY MEEEP DESC", 1, false, - "cmis:objectId", new String(), true); - testQuery("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder WHERE CONTAINS('cmis:name:*') AND cmis:name IN ('company', 'home') ORDER BY cmis:parentId DESC", 1, - false, "cmis:objectId", new String(), true); - testExtendedQuery("SELECT SCORE() AS MEEP, cmis:objectId, cmis:parentId FROM cmis:folder WHERE CONTAINS('cmis:name:*') ORDER BY cmis:parentId DESC", folder_count, false, - "cmis:objectId", new String(), false); - testQuery("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder WHERE CONTAINS('cmis:name:*') AND cmis:name IN ('company', 'home') ORDER BY cmis:notThere DESC", 1, - false, "cmis:objectId", new String(), true); - testQuery("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder as F WHERE CONTAINS('cmis:name:*') AND cmis:name IN ('company', 'home') ORDER BY F.cmis:parentId DESC", - 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT SCORE() AS MEEP, cmis:objectId FROM cmis:folder F WHERE CONTAINS('cmis:name:*') AND cmis:name IN ('company', 'home') ORDER BY F.cmis:notThere DESC", 1, - false, "cmis:objectId", new String(), true); - - } - - private void testOrderBy(String query, int size, boolean shouldThrow, Order order, CMISQueryMode mode, String... orderByPropertyName) - { - CMISResultSet rs = null; - try - { - CMISQueryOptions options = new CMISQueryOptions(query, rootNodeRef.getStoreRef()); - options.setQueryMode(mode); - rs = cmisQueryService.query(options); - Comparable[] previous = null; - boolean[] wasNull = null; - boolean[] hasValue = null; - - for (CMISResultSetRow row : rs) - { - if (previous == null) - { - previous = new Comparable[orderByPropertyName.length]; - wasNull = new boolean[orderByPropertyName.length]; - hasValue = new boolean[orderByPropertyName.length]; - for (int i = 0; i < orderByPropertyName.length; i++) - { - Serializable sValue = row.getValue(orderByPropertyName[i]); - if (sValue instanceof Comparable) - { - Comparable comparable = (Comparable) sValue; - previous[i] = comparable; - hasValue[i] = true; - } - else - { - previous[i] = null; - wasNull[i] = true; - } - - } - } - // if (row.getIndex() == 0) - // { - // Serializable sValue = row.getValue(returnPropertyName); - // returnValue = (T) DefaultTypeConverter.INSTANCE.convert(returnType.getClass(), sValue); - // - // } - else - { - for (int i = 0; i < orderByPropertyName.length; i++) - { - Serializable current = row.getValue(orderByPropertyName[i]); - Comparable last = previous[i]; - - if (last != null) - { - if (current == null) - { - switch (order) - { - case ASCENDING: - if (shouldThrow) - { - throw new IllegalStateException("Incorrect Order"); - } - else - { - fail("Null found after value ascending"); - } - case DESCENDING: - // OK - break; - default: - throw new UnsupportedOperationException(); - } - } - - int comparison = 0; - if(last instanceof String ) - { - Collator myCollator = Collator.getInstance(); - if(last == null) - { - if(current == null) - { - comparison = 0; - } - else - { - comparison = -1; - } - } - else - { - if(current == null) - { - comparison = 1; - } - else - { - comparison = myCollator.compare(last, current); - } - } - - - } - else - { - Method ct = null; - Method[] methods = last.getClass().getMethods(); - for (int m = 0; m < methods.length; m++) - { - if (methods[m].getName().equals("compareTo") - && (methods[m].getParameterTypes().length == 1) && (methods[m].getParameterTypes()[0].equals(methods[m].getDeclaringClass()))) - { - if (ct != null) - { - throw new IllegalStateException("Found 2 or more compareTo methods"); - } - ct = methods[m]; - } - } - comparison = (Integer) ct.invoke(last, current); - } - - - switch (order) - { - case ASCENDING: - if (comparison <= 0) - { // as expected - break; - } - else - { - if (shouldThrow) - { - throw new IllegalStateException("Incorrect Order"); - } - else - { - fail("Incorrect Order"); - } - } - case DESCENDING: - if (comparison >= 0) - { // as expected - break; - } - else - { - if (shouldThrow) - { - throw new IllegalStateException("Incorrect Order"); - } - else - { - fail("Incorrect Order"); - } - } - default: - throw new UnsupportedOperationException("Column data type is not comparable " + orderByPropertyName[i]); - } - } - else - { - if (current != null) - { - switch (order) - { - case ASCENDING: - // OK - break; - case DESCENDING: - if (shouldThrow) - { - throw new IllegalStateException("Incorrect Order"); - } - else - { - fail("Null found descending"); - } - default: - throw new UnsupportedOperationException(); - } - } - } - - } - for (int i = 0; i < orderByPropertyName.length; i++) - { - Serializable sValue = row.getValue(orderByPropertyName[i]); - if (sValue instanceof Comparable) - { - Comparable comparable = (Comparable) sValue; - previous[i] = comparable; - hasValue[i] = true; - } - else - { - previous[i] = null; - wasNull[i] = true; - } - - } - } - - } - for (int i = 0; i < hasValue.length; i++) - { - if (!hasValue[i]) - { - throw new UnsupportedOperationException("Only nulls found for " + orderByPropertyName[i]); - } - } - if (size >= 0) - { - assertEquals(size, rs.getLength()); - } - if (shouldThrow) - { - fail("Should have thrown an exception"); - } - - } - catch (CMISQueryException e) - { - if (shouldThrow) - { - return; - } - else - { - throw e; - } - } - catch (QueryModelException e) - { - if (shouldThrow) - { - return; - } - else - { - throw e; - } - } - catch (FTSQueryException e) - { - if (shouldThrow) - { - return; - } - else - { - throw e; - } - } - catch (UnsupportedOperationException e) - { - if (shouldThrow) - { - return; - } - else - { - throw e; - } - } - catch (IllegalArgumentException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - catch (InvocationTargetException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - catch (IllegalStateException e) - { - if (shouldThrow) - { - return; - } - else - { - throw e; - } - } - finally - { - if (rs != null) - { - try - { - rs.close(); - } - finally - { - rs = null; - } - } - } - - } - - public void testUpperAndLower() throws Exception - { - testExtendedQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'FOLDER 1'", 0, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'folder 1'", 0, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) = 'FOLDER 1'", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Lower(cmis:name) = 'folder 1'", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) = 'folder 1'", 0, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Lower(cmis:name) = 'FOLDER 1'", 0, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) = 'Folder 1'", 0, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Lower(cmis:name) = 'Folder 1'", 0, false, "cmis:objectId", new String(), false); - - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) <> 'FOLDER 1'", 9, false, "cmis:objectId", new String(), false); - - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) <= 'FOLDER 1'", 2, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) < 'FOLDER 1'", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) >= 'FOLDER 1'", 9, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:folder WHERE Upper(cmis:name) > 'FOLDER 1'", 8, false, "cmis:objectId", new String(), false); - } - - public void testAllSimpleTextPredicates() throws Exception - { - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name = 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name = 'Folder 9'", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name = 'Folder 9\\''", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND NOT cmis:name = 'Folder 1'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND 'Folder 1' = ANY cmis:name", 1, false, "cmis:objectId", new String(), true); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND NOT cmis:name <> 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name <> 'Folder 1'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name < 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name <= 'Folder 1'", 2, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name > 'Folder 1'", 8, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name >= 'Folder 1'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name IN ('Folder 1', '1')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name NOT IN ('Folder 1', 'Folder 9\\'')", 8, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND ANY cmis:name IN ('Folder 1', 'Folder 9\\'')", 2, false, "cmis:objectId", new String(), true); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND ANY cmis:name NOT IN ('2', '3')", 10, false, "cmis:objectId", new String(), true); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name LIKE 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name LIKE 'Fol%'", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name LIKE 'F_l_e_ 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name NOT LIKE 'F_l_e_ 1'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name LIKE 'F_l_e_ %'", 10, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name NOT LIKE 'F_l_e_ %'", 0, false, "cmis:objectId", new String(), false); - // TODO: Fix below which fail?? - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name LIKE 'F_l_e_ _'", 9, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name NOT LIKE 'F_l_e_ _'", 1, false, "cmis:objectId", new String(), false); - } - - public void testSimpleConjunction() throws Exception - { - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name = 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL AND cmis:name = 'Folder'", 0, false, "cmis:objectId", new String(), false); - } - - public void testSimpleDisjunction() throws Exception - { - testQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'Folder 2'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'Folder 1' OR cmis:name = 'Folder 2'", 2, false, "cmis:objectId", new String(), false); - } - - /** - * In strict mode you should not be able to refer to aspect properties direct from the type - * @throws Exception - */ - public void testPropertyToSelectorBinding() throws Exception - { - testQuery("SELECT cmis:parentId FROM cmis:document", 10, false, "cmis:objectId", new String(), true, CMISQueryMode.CMS_STRICT); - testQuery("SELECT * FROM cmis:document where cmis:parentId <> 'woof://woof/woof'", 10, false, "cmis:objectId", new String(), true, CMISQueryMode.CMS_STRICT); - testQuery("SELECT D.*, O.cmis:name FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId", 1, false, "cmis:objectId", new String(), true, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM cmis:document order by cmis:parentId", 10, false, "cmis:objectId", new String(), true, CMISQueryMode.CMS_STRICT); - testQuery("SELECT * FROM cmis:document where CONTAINS('cmis:parentId:*')", 10, false, "cmis:objectId", new String(), true, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - } - - public void testExists() throws Exception - { - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NOT NULL", folder_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name IS NULL", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE cmis:name IS NOT NULL", doc_count, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE cmis:name IS NULL", 0, false, "cmis:objectId", new String(), false); - } - - public void testObjectEquals() - { - - } - - public void testDocumentEquals() - { - - } - - public void testFolderEquals() throws Exception - { - Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_NAME); - String Name = DefaultTypeConverter.INSTANCE.convert(String.class, ser); - - testQuery("SELECT * FROM cmis:folder WHERE cmis:name = '" + Name + "'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:name = 'Folder 1'", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:parentId = '" + rootNodeRef.toString() + "'", 4, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE cmis:allowedChildObjectTypeIds = 'meep'", 0, false, "cmis:objectId", new String(), true); - } - - public void test_IN_TREE() throws Exception - { - Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); - String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser); - - testQuery("SELECT * FROM cmis:folder WHERE IN_TREE('" + id + "')", 6, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder F WHERE IN_TREE(F, '" + id + "')", 6, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder X WHERE IN_TREE(F, '" + id + "')", 6, false, "cmis:objectId", new String(), true); - - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId WHERE IN_TREE(D, '" + id + "')", 1, false, "cmis:objectId", - new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId WHERE IN_TREE('" + id + "')", 1, false, "cmis:objectId", - new String(), true, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId WHERE IN_TREE('" + id + ";versionLabel" +"')", 0, false, "cmis:objectId", - new String(), true, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - - testQuery("SELECT * FROM cmis:folder WHERE IN_TREE('woof://woof/woof')", 0, false, "cmis:objectId", new String(), true); - testQuery("SELECT * FROM cmis:folder WHERE IN_TREE('woof://woof/woof;woof')", 0, false, "cmis:objectId", new String(), true); - } - - public void test_IN_FOLDER() throws Exception - { - Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID); - String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser); - - testQuery("SELECT * FROM cmis:folder WHERE IN_FOLDER('" + id + "')", 2, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder F WHERE IN_FOLDER(F, '" + id + "')", 2, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder X WHERE IN_FOLDER(F, '" + id + "')", 2, false, "cmis:objectId", new String(), true); - - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId WHERE IN_FOLDER(D, '" + id + "')", 1, false, "cmis:objectId", - new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId WHERE IN_FOLDER('" + id + "')", 1, false, "cmis:objectId", - new String(), true, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId WHERE IN_FOLDER('" + id + ";versionLabel"+"')", 0, false, "cmis:objectId", - new String(), true, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - - // Note folders are unversioned - using a versoin lablel should find nothing - testQuery("SELECT * FROM cmis:folder WHERE IN_FOLDER('woof://woof/woof')", 0, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:folder WHERE IN_FOLDER('woof://woof/woof;woof')", 0, false, "cmis:objectId", new String(), false); - } - - public void testFTS() throws Exception - { - testQuery("SELECT SCORE(), D.* FROM cmis:document D WHERE D.cmis:contentStreamFileName = 'zebra'", doc_count-1, false, "cmis:objectId", new String(), true); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'zebra\\'') AND CONTAINS('\\'quick\\'')", doc_count-1, false, "cmis:objectId", new String(), true); - testQuery("SELECT SCORE()as ONE, SCORE()as TWO, D.* FROM cmis:document D WHERE CONTAINS('\\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'quick\\'')", 1, false, "cmis:objectId", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'quick\\'')", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document D WHERE CONTAINS(D, 'cmis:name:\\'Tutorial\\'')", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT cmis:name as BOO FROM cmis:document D WHERE CONTAINS('BOO:\\'Tutorial\\'')", 1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document D WHERE CONTAINS('TEXT:\\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document D WHERE CONTAINS('ALL:\\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document D WHERE CONTAINS('d:content:\\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false); - } - - public void testScoreValues() - { - - CMISQueryOptions options = new CMISQueryOptions("SELECT SCORE() AS ONE FROM cmis:document WHERE CONTAINS('cmis:name:\\'DD\\' and \\'Four\\'') AND cmis:name = 'DD\\''", - rootNodeRef.getStoreRef()); - options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.getLength()); - for (CMISResultSetRow row : rs) - { - System.out.println(row.getValue("cmis:objectId") + " Score " + row.getScore() + " " + row.getScores()); - } - rs.close(); - rs = null; - - options = new CMISQueryOptions("SELECT SCORE() AS ONE FROM cmis:document WHERE CONTAINS('\\'Four zebra durian\\'')", rootNodeRef.getStoreRef()); - rs = cmisQueryService.query(options); - assertEquals(1, rs.getLength()); - for (CMISResultSetRow row : rs) - { - System.out.println(row.getValue("cmis:objectId") + " Score " + row.getScore() + " " + row.getScores()); - } - rs.close(); - rs = null; - - options = new CMISQueryOptions("SELECT SCORE() AS ONE FROM cmis:document WHERE CONTAINS('\\'Zebra\\'')", rootNodeRef.getStoreRef()); - rs = cmisQueryService.query(options); - assertEquals(doc_count-1, rs.getLength()); - for (CMISResultSetRow row : rs) - { - System.out.println(row.getValue("cmis:objectId") + " Score " + row.getScore() + " " + row.getScores()); - } - rs.close(); - rs = null; - } - - public void testBasicSelectAsGuest() throws Exception - { - runAs("guest"); - testQuery("SELECT * FROM cmis:document", 0, false, "cmis:objectId", new String(), false); - - } - - public void testBasicSelectAsCmis() throws Exception - { - runAs("cmis"); - testQuery("SELECT * FROM cmis:document", doc_count-3, false, "cmis:objectId", new String(), false); - - } - - public void testBasicSelect() throws Exception - { - testQuery("SELECT * FROM cmis:document", doc_count, false, "cmis:objectId", new String(), false); - } - - public void testBasicDefaultMetaData() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document", rootNodeRef.getStoreRef()); - CMISResultSet rs = cmisQueryService.query(options); - CMISResultSetMetaData md = rs.getMetaData(); - assertNotNull(md.getQueryOptions()); - CMISTypeDefinition typeDef = cmisDictionaryService.findType(CMISDictionaryModel.DOCUMENT_TYPE_ID); - int count = 0; - for (CMISPropertyDefinition pdef : typeDef.getPropertyDefinitions().values()) - { - count++; - } - assertEquals(count, md.getColumnNames().length); - assertNotNull(md.getColumn(CMISDictionaryModel.PROP_OBJECT_ID)); - assertEquals(1, md.getSelectors().length); - assertNotNull(md.getSelector("")); - rs.close(); - } - - public void testBasicMetaData() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT DOC.cmis:objectId, DOC.cmis:objectId AS ID FROM cmis:document AS DOC", rootNodeRef.getStoreRef()); - CMISResultSet rs = cmisQueryService.query(options); - CMISResultSetMetaData md = rs.getMetaData(); - assertNotNull(md.getQueryOptions()); - assertEquals(2, md.getColumnNames().length); - assertNotNull(md.getColumn("DOC.cmis:objectId")); - assertNotNull(md.getColumn("ID")); - assertEquals(1, md.getSelectors().length); - assertNotNull(md.getSelector("DOC")); - rs.close(); - } - - public void testBasicColumns() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT DOC.cmis:objectId, DOC.cmis:objectTypeId AS ID FROM cmis:folder AS DOC", rootNodeRef.getStoreRef()); - CMISResultSet rs = cmisQueryService.query(options); - CMISResultSetMetaData md = rs.getMetaData(); - assertNotNull(md.getQueryOptions()); - assertEquals(2, md.getColumnNames().length); - assertNotNull(md.getColumn("DOC.cmis:objectId")); - assertNotNull(md.getColumn("ID")); - assertEquals(1, md.getSelectors().length); - assertNotNull(md.getSelector("DOC")); - for (CMISResultSetRow row : rs) - { - System.out.println("Id " + row.getValue("ID")); - } - rs.close(); - } - - public void testBasicAllDocumentColumns() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT DOC.* FROM cmis:document AS DOC", rootNodeRef.getStoreRef()); - CMISResultSet rs = cmisQueryService.query(options); - - CMISResultSetMetaData md = rs.getMetaData(); - - for (CMISResultSetRow row : rs) - { - for (String column : md.getColumnNames()) - { - System.out.println("Column " + column + " value =" + row.getValue(column)); - } - System.out.println("\n\n"); - } - rs.close(); - } - - public void testBasicAllFolderColumns() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:folder AS DOC", cmisService.getDefaultRootStoreRef()); - CMISResultSet rs = cmisQueryService.query(options); - - CMISResultSetMetaData md = rs.getMetaData(); - - for (CMISResultSetRow row : rs) - { - for (String column : md.getColumnNames()) - { - System.out.println("Column " + column + " value =" + row.getValue(column)); - } - System.out.println("\n\n"); - } - rs.close(); - } - - public void testBasicAll_ST_SITES_Columns() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM ST:SITES AS DOC", cmisService.getDefaultRootStoreRef()); - CMISResultSet rs = cmisQueryService.query(options); - - CMISResultSetMetaData md = rs.getMetaData(); - - for (CMISResultSetRow row : rs) - { - for (String column : md.getColumnNames()) - { - System.out.println("Column " + column + " value =" + row.getValue(column)); - } - System.out.println("\n\n"); - System.out.println(row.getValues()); - System.out.println("\n\n"); - } - - rs.close(); - } - - public void testFunctionColumns() - { - CMISQueryOptions options = new CMISQueryOptions( - "SELECT DOC.cmis:name AS cmis:name, \nLOWER(\tDOC.cmis:name \n), LOWER ( DOC.cmis:name ) AS Lcmis:name, UPPER ( DOC.cmis:name ) , UPPER(DOC.cmis:name) AS Ucmis:name, Score(), SCORE() AS S1, SCORE() AS SCORED FROM cmis:folder AS DOC", - rootNodeRef.getStoreRef()); - options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - CMISResultSet rs = cmisQueryService.query(options); - - CMISResultSetMetaData md = rs.getMetaData(); - assertNotNull(md.getQueryOptions()); - assertEquals(8, md.getColumnNames().length); - assertNotNull(md.getColumn("cmis:name")); - assertNotNull(md.getColumn("LOWER(\tDOC.cmis:name \n)")); - assertNotNull(md.getColumn("Lcmis:name")); - assertNotNull(md.getColumn("UPPER ( DOC.cmis:name )")); - assertNotNull(md.getColumn("Ucmis:name")); - assertNotNull(md.getColumn("SEARCH_SCORE")); - assertNotNull(md.getColumn("S1")); - assertNotNull(md.getColumn("SCORED")); - assertEquals(1, md.getSelectors().length); - assertNotNull(md.getSelector("DOC")); - for (CMISResultSetRow row : rs) - { - System.out.println("\n\n"); - System.out.println(row.getValues()); - System.out.println("\n\n"); - } - rs.close(); - } - - public void testParse1() throws RecognitionException - { - String query = "SELECT UPPER(1.0) AS WOOF FROM cmis:document AS DOC LEFT OUTER JOIN cmis:folder AS FOLDER ON DOC.cmis:name = FOLDER.cmis:name WHERE LOWER(DOC.cmis:name) = ' woof' AND CONTAINS('one two three') AND CONTAINS('DOC.cmis:name:lemur AND woof') AND (DOC.cmis:name in ('one', 'two') AND IN_FOLDER('meep') AND DOC.cmis:name like 'woof' and DOC.cmis:name = 'woof' and DOC.cmis:objectId = 'meep') ORDER BY DOC.cmis:name DESC, WOOF"; - parse(query); - } - - public void testParse2() throws RecognitionException - { - String query = "SELECT TITLE, AUTHORS, DATE FROM WHITE_PAPER WHERE ( IN_TREE( 'ID00093854763') ) AND ( 'SMITH' = ANY AUTHORS )"; - parse(query); - } - - public void testParse3() throws RecognitionException - { - String query = "SELECT cmis:objectId, SCORE() AS X, DESTINATION, DEPARTURE_DATES FROM TRAVEL_BROCHURE WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND ( '2009-1-1' < ANY DEPARTURE_DATES ) ORDER BY X DESC"; - parse(query); - } - - public void testParse4() throws RecognitionException - { - String query = "SELECT * FROM CAR_REVIEW WHERE ( LOWER(MAKE) = 'buick' ) OR ( ANY FEATURES IN ('NAVIGATION SYSTEM', 'SATELLITE RADIO', 'MP3' ) )"; - parse(query); - } - - public void testParse5() throws RecognitionException - { - String query = "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )"; - parse(query); - } - - public void testParse6() throws RecognitionException - { - String query = "SELECT * FROM CM_TITLED"; - parse(query); - query = "SELECT D.*, T.* FROM DOCUMENT AS D JOIN CM_TITLED AS T ON D.OBJECTID = T.OBJECTID"; - parse(query); - query = "SELECT D.*, T.* FROM CM_TITLED T JOIN DOCUMENT D ON D.OBJECTID = T.OBJECTID"; - parse(query); - } - - public void testParse7() throws RecognitionException - { - String query = "SELECT * from DOCUMENT D JOIN DOCUMENT DD ON D.ID = DD.ID "; - parse(query); - } - - public void testParse8() throws RecognitionException - { - String query = "SELECT * from ((FOLDER F JOIN RELATIONSHIP RL ON F.ID = RL.ID))"; - parse(query); - } - - public void testDateFormattingErrors() throws Exception - { - testQuery("SELECT * FROM cm:lockable L WHERE L.cm:expiryDate = TIMESTAMP '2012-12-12T12:12:12.012Z'", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM cm:lockable L WHERE L.cm:expiryDate = TIMESTAMP '2012-012-12T12:12:12.012Z'", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM cm:lockable L WHERE L.cm:expiryDate = TIMESTAMP '2012-2-12T12:12:12.012Z'", 0, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM cm:lockable L WHERE L.cm:expiryDate = TIMESTAMP 'Mon Dec 12 12:12:12.012 GMT 2012'", 1, false, "cmis:objectId", new String(), true, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - } - - public void testAspectProperties() - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM CM:OWNABLE O", rootNodeRef.getStoreRef()); - options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - - CMISResultSet rs = cmisQueryService.query(options); - - CMISResultSetMetaData md = rs.getMetaData(); - assertNotNull(md.getQueryOptions()); - assertEquals(1, md.getColumnNames().length); - assertNotNull(md.getColumn("O.cm:owner")); - assertEquals(1, md.getSelectors().length); - assertNotNull(md.getSelector("O")); - for (CMISResultSetRow row : rs) - { - System.out.println("\n\n"); - System.out.println(row.getValues()); - System.out.println("\n\n"); - } - rs.close(); - } - - public void testAspectJoin() throws Exception - { - testQuery( - "select o.*, t.* from ( cm:ownable o join cm:titled t on o.cmis:objectId = t.cmis:objectId JOIN CMIS:DOCUMENT AS D ON D.cmis:objectId = o.cmis:objectId ) where o.cm:owner = 'andy' and t.cm:title = 'Alfresco tutorial' and CONTAINS(D, '\\'jumped\\'') and D.cmis:contentStreamLength <> 2", - 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - - testQuery("SELECT * FROM CM:OWNABLE", 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM CM:OWNABLE where CM:oWNER = 'andy'", 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM CM:OWNABLE where CM:OWNER = 'bob'", 0, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery( - "SELECT D.*, O.*, T.* FROM CMIS:DOCUMENT AS D JOIN CM:OWNABLE AS O ON D.cmis:objectId = O.cmis:objectId JOIN CM:TITLED AS T ON T.cmis:objectId = D.cmis:objectId", - 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, O.* FROM CM:OWNABLE O JOIN CMIS:DOCUMENT D ON D.cmis:objectId = O.cmis:objectId", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT D.*, F.* FROM CMIS:FOLDER F JOIN CMIS:DOCUMENT D ON D.cmis:objectId = F.cmis:objectId", 0, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT O.*, T.* FROM CM:OWNABLE O JOIN CM:TITLED T ON O.cmis:objectId = T.cmis:objectId", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("select o.*, t.* from cm:ownable o join cm:titled t on o.cmis:objectId = t.cmis:objectId", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("sElEcT o.*, T.* fRoM cM:oWnAbLe o JoIn Cm:TiTlEd T oN o.cmis:objectId = T.cmis:objectId", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("select o.*, t.* from ( cm:ownable o join cm:titled t on o.cmis:objectId = t.cmis:objectId )", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("select o.*, t.* from ( cm:ownable o join cm:titled t on o.cmis:objectId = t.cmis:objectId JOIN CMIS:DOCUMENT AS D ON D.cmis:objectId = o.cmis:objectId )", 1, - false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery( - "select o.*, t.* from ( cm:ownable o join cm:titled t on o.cmis:objectId = t.cmis:objectId JOIN CMIS:DOCUMENT AS D ON D.cmis:objectId = o.cmis:objectId ) where o.cm:owner = 'andy' and t.cm:title = 'Alfresco tutorial' and CONTAINS(D, '\\'jumped\\'') and D.cmis:contentStreamLength <> 2", - 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery( - "select o.*, t.* from ( cm:ownable o join cm:titled t on o.cmis:objectId = t.cmis:objectId JOIN CMIS:DOCUMENT AS D ON D.cmis:objectId = o.cmis:objectId ) where o.cm:owner = 'andy' and t.cm:title = 'Alfresco tutorial' and CONTAINS(D, 'jumped') and D.cmis:contentStreamLength <> 2", - 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - } - - public void testPaging() - { - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - List expected = new ArrayList(10); - - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(10, rs.getLength()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectId"); - String id = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - expected.add(id); - } - rs.close(); - - for (int skip = 0; skip < 20; skip++) - { - for (int max = 0; max < 20; max++) - { - doPage(expected, skip, max); - } - } - - } - - public void testFTSConnectives() throws Exception - { - testQuery("SELECT * FROM cmis:document where contains('\\'one\\' OR \\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_STRICT); - testQuery("SELECT * FROM cmis:document where contains('\\'one\\' or \\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_STRICT); - testQuery("SELECT * FROM cmis:document where contains('\\'one\\' \\'zebra\\'')", 1, false, "cmis:objectId", new String(), false, CMISQueryMode.CMS_STRICT); - testQuery("SELECT * FROM cmis:document where contains('\\'one\\' and \\'zebra\\'')", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM cmis:document where contains('\\'one\\' or \\'zebra\\'')", doc_count-1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - testQuery("SELECT * FROM cmis:document where contains('\\'one\\' \\'zebra\\'')", 1, false, "cmis:objectId", new String(), false, - CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:document where contains('\\'one\\' \\'zebra\\'')", rootNodeRef.getStoreRef()); - // options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM cmis:document where contains('\\'one\\' \\'zebra\\'')", rootNodeRef.getStoreRef()); - options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); - rs = cmisQueryService.query(options); - assertEquals(doc_count-1, rs.length()); - rs.close(); - } - - public void testLikeEscaping() throws Exception - { - // TODO: - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco Tutorial'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco Tutoria_'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco T_______'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco T______\\_'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco T%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'Alfresco T\\%'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'GG*GG'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE '__*__'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE '%*%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'HH?HH'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE '__?__'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE '%?%'", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'AA%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'AA\\%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'A%'", 2, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'a%'", 2, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'A\\%'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'BB_'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'BB\\_'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'B__'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'B_\\_'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'B\\_\\_'", 0, false, "cmis:name", new String(), false); - - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'CC\\\\'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT cmis:name FROM cmis:document WHERE cmis:name LIKE 'DD\\''", 1, false, "cmis:name", new String(), false); - } - - public void testColumnAliasUse() throws Exception - { - testQuery("SELECT cmis:name as myname FROM cmis:document WHERE myname LIKE 'Alfresco Tutorial'", 1, false, "myname", new String(), false); - testQuery("SELECT cmis:name as myname FROM cmis:document WHERE myname LIKE 'A%' order by myname", 2, false, "cmis:name", new String(), false); - testExtendedQuery("SELECT SCORE() as myscore, D.cmis:name as myname FROM cmis:document D WHERE CONTAINS(D, 'myname:\\'Tutorial\\'') order by myscore", 1, false, - "cmis:objectId", new String(), false); - testExtendedQuery("SELECT SCORE() as myscore, D.cmis:name FROM cmis:document D WHERE CONTAINS(D, 'cmis:name:\\'Tutorial\\'') and myscore > 0.5 order by myscore", 9, false, - "cmis:objectId", new String(), true); - - } - - private void doPage(List expected, int skip, int max) - { - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM cmis:folder", rootNodeRef.getStoreRef()); - options.setSkipCount(skip); - options.setMaxItems(max); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals("Skip = " + skip + " max = " + max, skip + max > 10 ? Math.max(10 - skip, 0) : max, rs.getLength()); - assertEquals("Skip = " + skip + " max = " + max, (skip + max) < 10, rs.hasMore()); - assertEquals("Skip = " + skip + " max = " + max, skip, rs.getStart()); - int actualPosition = skip; - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("cmis:objectId"); - String id = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("Skip = " + skip + " max = " + max + " actual = " + actualPosition, expected.get(actualPosition), id); - actualPosition++; - } - } - - private CommonTree parse(String query) throws RecognitionException - { - CharStream cs = new ANTLRStringStream(query); - CMISLexer lexer = new CMISLexer(cs); - CommonTokenStream tokens = new CommonTokenStream(lexer); - CMISParser parser = new CMISParser(tokens); - CommonTree queryNode = (CommonTree) parser.query().getTree(); - return queryNode; - } - - public void test_d_text() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleTextBoth"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("Un tokenised", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleTextBoth"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:singleTextUntokenised"); - value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("Un tokenised", value); - column = rs.getResultSetMetaData().getColumn("test:singleTextUntokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:singleTextTokenised"); - value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("Un tokenised", value); - column = rs.getResultSetMetaData().getColumn("test:singleTextTokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleTextBoth"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(String.class, sValue); - assertEquals(2, collection.size()); - String[] members = new String[2]; - members = collection.toArray(members); - assertEquals("Un tokenised", members[0]); - assertEquals("two parts", members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleTextBoth"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleTextUntokenised"); - assert (sValue instanceof Collection); - collection = DefaultTypeConverter.INSTANCE.getCollection(String.class, sValue); - assertEquals(2, collection.size()); - members = new String[2]; - members = collection.toArray(members); - assertEquals("Un tokenised", members[0]); - assertEquals("two parts", members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleTextUntokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleTextTokenised"); - assert (sValue instanceof Collection); - collection = DefaultTypeConverter.INSTANCE.getCollection(String.class, sValue); - assertEquals(2, collection.size()); - members = new String[2]; - members = collection.toArray(members); - assertEquals("Un tokenised", members[0]); - assertEquals("two parts", members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleTextTokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:text single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth = 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth <> 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'Un tokenised' = ANY test:singleTextBoth ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleTextBoth IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleTextBoth NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth < 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth < 'Un tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth < 'V'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth < 'U'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth <= 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth <= 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth <= 'V'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth <= 'U'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth > 'tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth > 'Un tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth > 'V'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth > 'U'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth >= 'tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth >= 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth >= 'V'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextBoth >= 'U'", 1, false, "cmis:name", new String(), false); - - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised = 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised <> 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'Un tokenised' = ANY test:singleTextUntokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleTextUntokenised IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleTextUntokenised NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised < 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised < 'Un tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised < 'V'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised < 'U'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised <= 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised <= 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised <= 'V'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised <= 'U'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised > 'tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised > 'Un tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised > 'V'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised > 'U'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised >= 'tokenised'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised >= 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised >= 'V'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextUntokenised >= 'U'", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextTokenised = 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextTokenised <> 'tokenized'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextTokenised LIKE 'to%sed'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextTokenised NOT LIKE 'Ut__eniz%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextTokenised IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleTextTokenised NOT IN ('tokenized')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'tokenised' = ANY test:singleTextTokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleTextTokenised IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleTextTokenised NOT IN ('tokenized')", 1, false, "cmis:name", new String(), true); - // Ranges do not make a lot of sense for tokenized fields - - // d:text single by alias - - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE alias = 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE alias <> 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE alias LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE alias NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE 'Un tokenised' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE ANY alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:singleTextBoth as alias FROM test:extendedContent as T WHERE ANY alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE alias = 'Un tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE alias <> 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE alias LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE alias NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), - false); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE 'Un tokenised' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE ANY alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), - true); - testQuery("SELECT T.test:singleTextUntokenised as alias FROM test:extendedContent as T WHERE ANY alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE alias = 'tokenised'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE alias <> 'tokenized'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE alias LIKE 'to%sed'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE alias NOT LIKE 'Ut__eniz%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE alias IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE alias NOT IN ('tokenized')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE 'tokenised' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE ANY alias IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleTextTokenised as alias FROM test:extendedContent WHERE ANY alias NOT IN ('tokenized')", 1, false, "cmis:name", new String(), true); - - // d:text multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextBoth = 'Un tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextBoth <> 'tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextBoth LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextBoth NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextBoth IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextBoth NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'Un tokenised' = ANY test:multipleTextBoth ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleTextBoth IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleTextBoth NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextUntokenised = 'Un tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextUntokenised <> 'tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextUntokenised LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextUntokenised NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextUntokenised IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextUntokenised NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'Un tokenised' = ANY test:multipleTextUntokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleTextUntokenised IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleTextUntokenised NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextTokenised = 'tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextTokenised <> 'tokenized'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextTokenised LIKE 'to%sed'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextTokenised NOT LIKE 'Ut__eniz%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextTokenised IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleTextTokenised NOT IN ('tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'tokenised' = ANY test:multipleTextTokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleTextTokenised IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleTextTokenised NOT IN ('tokenized')", 1, false, "cmis:name", new String(), false); - - // d:text multiple by alias - - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE alias = 'Un tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE alias <> 'tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE alias LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE alias NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE 'Un tokenised' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE ANY alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleTextBoth as alias FROM test:extendedContent WHERE ANY alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE alias = 'Un tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE alias <> 'tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE alias LIKE 'U_ to%sed'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE alias NOT LIKE 't__eni%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE 'Un tokenised' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE ANY alias IN ('Un tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleTextUntokenised alias FROM test:extendedContent WHERE ANY alias NOT IN ('Un tokenized')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE alias = 'tokenised'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE alias <> 'tokenized'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE alias LIKE 'to%sed'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE alias NOT LIKE 'Ut__eniz%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE alias IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE alias NOT IN ('tokenized')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE 'tokenised' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE ANY alias IN ('tokenised', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT T.test:multipleTextTokenised alias FROM test:extendedContent T WHERE ANY alias NOT IN ('tokenized')", 1, false, "cmis:name", new String(), false); - } - - public void test_locale() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA BBBB'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.ENGLISH)); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA BBBB'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.FRENCH)); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA BBBB'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.FRENCH)); - options.setMlAnalaysisMode(MLAnalysisMode.ALL_LANGUAGES); - rs = cmisQueryService.query(options); - assertEquals(0, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.ENGLISH)); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.ENGLISH)); - options.setMlAnalaysisMode(MLAnalysisMode.ALL_LANGUAGES); - rs = cmisQueryService.query(options); - assertEquals(0, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.FRENCH)); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setLocales(Collections.singletonList(Locale.FRENCH)); - options.setIncludeInTransactionData(false); - rs = cmisQueryService.query(options); - assertEquals(0, rs.length()); - rs.close(); - - I18NUtil.setLocale(Locale.UK); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA BBBB'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setMlAnalaysisMode(MLAnalysisMode.ALL_LANGUAGES); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setMlAnalaysisMode(MLAnalysisMode.ALL_LANGUAGES); - rs = cmisQueryService.query(options); - assertEquals(0, rs.length()); - rs.close(); - - I18NUtil.setLocale(Locale.FRANCE); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA BBBB'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setMlAnalaysisMode(MLAnalysisMode.ALL_LANGUAGES); - rs = cmisQueryService.query(options); - assertEquals(0, rs.length()); - rs.close(); - - options = new CMISQueryOptions("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - options.setMlAnalaysisMode(MLAnalysisMode.ALL_LANGUAGES); - rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - rs.close(); - } - - public void test_d_mltext() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleMLTextBoth"); - String value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("AAAA BBBB", value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleMLTextBoth"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:singleMLTextUntokenised"); - value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("AAAA BBBB", value); - column = rs.getResultSetMetaData().getColumn("test:singleMLTextUntokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:singleMLTextTokenised"); - value = DefaultTypeConverter.INSTANCE.convert(String.class, sValue); - assertEquals("AAAA BBBB", value); - column = rs.getResultSetMetaData().getColumn("test:singleMLTextTokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleMLTextBoth"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(String.class, sValue); - assertEquals(1, collection.size()); - String[] members = new String[1]; - members = collection.toArray(members); - assertEquals("AAAA BBBB", members[0]); - column = rs.getResultSetMetaData().getColumn("test:multipleMLTextBoth"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleMLTextUntokenised"); - assert (sValue instanceof Collection); - collection = DefaultTypeConverter.INSTANCE.getCollection(String.class, sValue); - assertEquals(1, collection.size()); - members = new String[1]; - members = collection.toArray(members); - assertEquals("AAAA BBBB", members[0]); - column = rs.getResultSetMetaData().getColumn("test:multipleMLTextUntokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleMLTextTokenised"); - assert (sValue instanceof Collection); - collection = DefaultTypeConverter.INSTANCE.getCollection(String.class, sValue); - assertEquals(1, collection.size()); - members = new String[1]; - members = collection.toArray(members); - assertEquals("AAAA BBBB", members[0]); - column = rs.getResultSetMetaData().getColumn("test:multipleMLTextTokenised"); - assertEquals(CMISDataTypeEnum.STRING, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // Note language agnostic tokenisation included in the default settings includes matches you may not expect - // Corss language search support - - // d:mltext single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA BBBB'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'AAAA'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = '%AAAA'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = '%AAA'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'BBBB'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth = 'CCCC DDDD'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth NOT LIKE 'B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth NOT LIKE 'D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextBoth NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'AAAA BBBB' = ANY test:singleMLTextBoth ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'CCCC DDDD' = ANY test:singleMLTextBoth ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextBoth IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextBoth IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextBoth NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised = 'AAAA BBBB'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised = 'CCCC DDDD'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised NOT LIKE 'B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised NOT LIKE 'D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextUntokenised NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'AAAA BBBB' = ANY test:singleMLTextUntokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'CCCC DDDD' = ANY test:singleMLTextUntokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextUntokenised IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextUntokenised IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextUntokenised NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised = 'AAAA'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised = 'BBBB'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised = 'CCCC'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised = 'DDDD'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised <> 'EEEE'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised LIKE 'A%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised LIKE '_B__'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised LIKE '%C'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised LIKE 'D%D'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised NOT LIKE 'CCCC_'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleMLTextTokenised NOT IN ('EEEE')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'AAAA' = ANY test:singleMLTextTokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'BBBB' = ANY test:singleMLTextTokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'CCCC' = ANY test:singleMLTextTokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'DDDD' = ANY test:singleMLTextTokenised ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextTokenised IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextTokenised IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextTokenised IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextTokenised IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleMLTextTokenised NOT IN ('EEEE')", 1, false, "cmis:name", new String(), true); - - // d:mltext single by alias - - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias = 'AAAA BBBB'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias = 'AAAA'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias = 'BBBB'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias = 'CCCC DDDD'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias NOT LIKE 'B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias NOT LIKE 'D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE 'AAAA BBBB' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE 'CCCC DDDD' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE ANY alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE ANY alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextBoth as alias FROM test:extendedContent WHERE ANY alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias = 'AAAA BBBB'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias = 'CCCC DDDD'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias NOT LIKE 'B%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias NOT LIKE 'D%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE 'AAAA BBBB' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE 'CCCC DDDD' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE ANY alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE ANY alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextUntokenised as alias FROM test:extendedContent WHERE ANY alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias = 'AAAA'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias = 'BBBB'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias = 'CCCC'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias = 'DDDD'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias <> 'EEEE'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias LIKE 'A%'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias LIKE '_B__'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias LIKE '%C'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias LIKE 'D%D'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias NOT LIKE 'CCCC_'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE alias NOT IN ('EEEE')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE 'AAAA' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE 'BBBB' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE 'CCCC' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE 'DDDD' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE ANY alias IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE ANY alias IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE ANY alias IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE ANY alias IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleMLTextTokenised as alias FROM test:extendedContent WHERE ANY alias NOT IN ('EEEE')", 1, false, "cmis:name", new String(), true); - - // d:mltext multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth = 'AAAA BBBB'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth = 'AAAA'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth = 'BBBB'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth = 'CCCC DDDD'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth NOT LIKE 'B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth NOT LIKE 'D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextBoth NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'AAAA BBBB' = ANY test:multipleMLTextBoth ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'CCCC DDDD' = ANY test:multipleMLTextBoth ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextBoth IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextBoth IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextBoth NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised = 'AAAA BBBB'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised = 'CCCC DDDD'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised NOT LIKE 'B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised NOT LIKE 'D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextUntokenised NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'AAAA BBBB' = ANY test:multipleMLTextUntokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'CCCC DDDD' = ANY test:multipleMLTextUntokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextUntokenised IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextUntokenised IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextUntokenised NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised = 'AAAA'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised = 'BBBB'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised = 'CCCC'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised = 'DDDD'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised <> 'EEEE'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised LIKE 'A%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised LIKE '_B__'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised LIKE '%C'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised LIKE 'D%D'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised NOT LIKE 'CCCC_'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleMLTextTokenised NOT IN ('EEEE')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE 'AAAA' = ANY test:multipleMLTextTokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'BBBB' = ANY test:multipleMLTextTokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'CCCC' = ANY test:multipleMLTextTokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE 'DDDD' = ANY test:multipleMLTextTokenised ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextTokenised IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextTokenised IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextTokenised IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextTokenised IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleMLTextTokenised NOT IN ('EEEE')", 1, false, "cmis:name", new String(), false); - - // d:mltext multiple by alias - - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias = 'AAAA BBBB'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias = 'AAAA'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias = 'BBBB'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias = 'CCCC DDDD'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias NOT LIKE 'B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias NOT LIKE 'D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE 'AAAA BBBB' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE 'CCCC DDDD' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE ANY alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE ANY alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextBoth alias FROM test:extendedContent WHERE ANY alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias = 'AAAA BBBB'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias = 'CCCC DDDD'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias <> 'EEEE FFFF'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias LIKE 'AAA_ B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias LIKE 'CCC_ D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias NOT LIKE 'B%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias NOT LIKE 'D%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE 'AAAA BBBB' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE 'CCCC DDDD' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE ANY alias IN ('AAAA BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE ANY alias IN ('CCCC DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextUntokenised alias FROM test:extendedContent WHERE ANY alias NOT IN ('EEEE FFFF')", 1, false, "cmis:name", new String(), false); - - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias = 'AAAA'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias = 'BBBB'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias = 'CCCC'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias = 'DDDD'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias <> 'EEEE'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias LIKE 'A%'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias LIKE '_B__'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias LIKE '%C'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias LIKE 'D%D'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias NOT LIKE 'CCCC_'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE alias NOT IN ('EEEE')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE 'AAAA' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE 'BBBB' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE 'CCCC' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE 'DDDD' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE ANY alias IN ('AAAA', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE ANY alias IN ('BBBB', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE ANY alias IN ('CCCC', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE ANY alias IN ('DDDD', 'Monkey')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleMLTextTokenised alias FROM test:extendedContent WHERE ANY alias NOT IN ('EEEE')", 1, false, "cmis:name", new String(), false); - } - - public void test_d_float() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleFloat"); - Float value = DefaultTypeConverter.INSTANCE.convert(Float.class, sValue); - assertEquals(1.0f, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleFloat"); - assertEquals(CMISDataTypeEnum.DECIMAL, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleFloat"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Float.class, sValue); - assertEquals(2, collection.size()); - Float[] members = new Float[2]; - members = collection.toArray(members); - assertEquals(1.0f, members[0]); - assertEquals(1.1f, members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleFloat"); - assertEquals(CMISDataTypeEnum.DECIMAL, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:float single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat = 1.1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat <> 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat < 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat <= 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat > 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat >= 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleFloat NOT IN (1.1)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:singleFloat ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1.1' = ANY test:singleFloat ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleFloat IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleFloat NOT IN (1.1, 2.2)", 1, false, "cmis:name", new String(), true); - - // d:float single by alias - - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias = 1.1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias <> 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias < 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias <= 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias > 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias >= 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE alias NOT IN (1.1)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE '1.1' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleFloat as alias FROM test:extendedContent WHERE ANY alias NOT IN (1.1, 2.2)", 1, false, "cmis:name", new String(), true); - - // d:float multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat = 1.1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat <> 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat < 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat <= 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat > 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat >= 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleFloat NOT IN (1.1)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:multipleFloat ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '1.1' = ANY test:multipleFloat ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleFloat IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleFloat IN (1.1, 2.2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleFloat NOT IN (1.1, 2.2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleFloat NOT IN (1.3, 2.3)", 1, false, "cmis:name", new String(), false); - - // d:float multiple by alias - - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias = 1.1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias <> 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias < 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias <= 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias > 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias >= 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE alias NOT IN (1.1)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE '1.1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE ANY alias IN (1.1, 2.2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE ANY alias NOT IN (1.1, 2.2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleFloat as alias FROM test:extendedContent WHERE ANY alias NOT IN (1.3, 2.3)", 1, false, "cmis:name", new String(), false); - } - - public void test_d_double() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleDouble"); - Double value = DefaultTypeConverter.INSTANCE.convert(Double.class, sValue); - assertEquals(1.0d, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleDouble"); - assertEquals(CMISDataTypeEnum.DECIMAL, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleDouble"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Double.class, sValue); - assertEquals(2, collection.size()); - Double[] members = new Double[2]; - members = collection.toArray(members); - assertEquals(1.0d, members[0]); - assertEquals(1.1d, members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleDouble"); - assertEquals(CMISDataTypeEnum.DECIMAL, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:double single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble = 1.1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble <> 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble < 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble <= 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble > 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble >= 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDouble NOT IN (1.1)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:singleDouble ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1.1' = ANY test:singleDouble ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleDouble IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleDouble NOT IN (1.1, 2.2)", 1, false, "cmis:name", new String(), true); - - // d:double single by alias - - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias = 1.1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias <> 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias < 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias <= 1.1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias > 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias >= 0.9", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE alias NOT IN (1.1)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE '1.1' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDouble alias FROM test:extendedContent WHERE ANY alias NOT IN (1.1, 2.2)", 1, false, "cmis:name", new String(), true); - - // d:double multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble = 1.1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble <> 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble < 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble <= 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble > 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble >= 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDouble NOT IN (1.1)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:multipleDouble ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '1.1' = ANY test:multipleDouble ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDouble IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDouble IN (1.1, 2.2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDouble NOT IN (1.1, 2.2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDouble NOT IN (1.3, 2.3)", 1, false, "cmis:name", new String(), false); - - // d:double multiple by alias - - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias = 1.1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias <> 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias < 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias <= 1.1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias > 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias >= 0.9", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE alias NOT IN (1.1)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE '1.1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE ANY alias IN (1.1, 2.2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE ANY alias NOT IN (1.1, 2.2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDouble alias FROM test:extendedContent WHERE ANY alias NOT IN (1.3, 2.3)", 1, false, "cmis:name", new String(), false); - } - - public void test_d_int() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleInteger"); - Integer value = DefaultTypeConverter.INSTANCE.convert(Integer.class, sValue); - assertEquals(Integer.valueOf(1), value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleInteger"); - assertEquals(CMISDataTypeEnum.INTEGER, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleInteger"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Integer.class, sValue); - assertEquals(2, collection.size()); - Integer[] members = new Integer[2]; - members = collection.toArray(members); - assertEquals(Integer.valueOf(1), members[0]); - assertEquals(Integer.valueOf(2), members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleInteger"); - assertEquals(CMISDataTypeEnum.INTEGER, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:int single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger = 2", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger <> 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger < 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger <= 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger > 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger >= 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleInteger NOT IN (2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:singleInteger ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '2' = ANY test:singleInteger ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleInteger IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleInteger NOT IN (2, 3)", 1, false, "cmis:name", new String(), true); - - // d:int single by alias - - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias = 2", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias <> 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias < 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias <= 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias > 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias >= 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE alias NOT IN (2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE '2' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleInteger alias FROM test:extendedContent WHERE ANY alias NOT IN (2, 3)", 1, false, "cmis:name", new String(), true); - - // d:int multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger = 2", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger <> 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger < 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger <= 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger > 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger >= 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleInteger NOT IN (2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:multipleInteger ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '2' = ANY test:multipleInteger ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleInteger IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleInteger IN (2, 3)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleInteger NOT IN (1, 2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleInteger NOT IN (2, 3)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleInteger NOT IN (3, 4)", 1, false, "cmis:name", new String(), false); - - // d:int multiple by alias - - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias = 2", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias <> 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias < 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias <= 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias > 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias >= 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE alias NOT IN (2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE '2' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE ANY alias IN (2, 3)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE ANY alias NOT IN (1, 2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE ANY alias NOT IN (2, 3)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleInteger as alias FROM test:extendedContent WHERE ANY alias NOT IN (3, 4)", 1, false, "cmis:name", new String(), false); - } - - public void test_d_long() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleLong"); - Long value = DefaultTypeConverter.INSTANCE.convert(Long.class, sValue); - assertEquals(Long.valueOf(1), value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleLong"); - assertEquals(CMISDataTypeEnum.INTEGER, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleLong"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Long.class, sValue); - assertEquals(2, collection.size()); - Long[] members = new Long[2]; - members = collection.toArray(members); - assertEquals(Long.valueOf(1), members[0]); - assertEquals(Long.valueOf(2), members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleLong"); - assertEquals(CMISDataTypeEnum.INTEGER, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:long single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong = 2", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong <> 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong < 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong <= 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong > 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong >= 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleLong NOT IN (2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:singleLong ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '2' = ANY test:singleLong ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleLong IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleLong NOT IN (2, 3)", 1, false, "cmis:name", new String(), true); - - // d:long single by alias - - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias = 2", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias <> 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias < 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias <= 2", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias > 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias >= 0", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE alias NOT IN (2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE '2' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleLong as alias FROM test:extendedContent WHERE ANY alias NOT IN (2, 3)", 1, false, "cmis:name", new String(), true); - - // d:long multiple - - testQuery("SELECT alias FROM test:extendedContent WHERE test:multipleLong = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong = 2", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong <> 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong < 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong <= 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong > 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong >= 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleLong NOT IN (2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:multipleLong ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '2' = ANY test:multipleLong ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleLong IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleLong IN (2, 3)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleLong NOT IN (1, 2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleLong NOT IN (2, 3)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleLong NOT IN (3, 4)", 1, false, "cmis:name", new String(), false); - - // d:long multiple by alias - - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias = 2", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias <> 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias < 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias <= 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias > 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias >= 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE alias NOT IN (2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE '2' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE ANY alias IN (2, 3)", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE ANY alias NOT IN (1, 2)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE ANY alias NOT IN (2, 3)", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleLong alias FROM test:extendedContent WHERE ANY alias NOT IN (3, 4)", 1, false, "cmis:name", new String(), false); - } - - public void test_d_date() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleDate"); - Date value = DefaultTypeConverter.INSTANCE.convert(Date.class, sValue); - assertEquals(date1, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleDate"); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleDate"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Date.class, sValue); - assertEquals(2, collection.size()); - Date[] members = new Date[2]; - members = collection.toArray(members); - assertEquals(date1, members[0]); - assertEquals(date2, members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleDate"); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:date single - - SimpleDateFormat df1 = new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSSZ"); - - String d0 = df1.format(date0); - StringBuilder builder = new StringBuilder(); - builder.append(d0); - builder.insert(builder.length() - 2, ':'); - d0 = builder.toString(); - - String d1 = df1.format(date1); - builder = new StringBuilder(); - builder.append(d1); - builder.insert(builder.length() - 2, ':'); - d1 = builder.toString(); - - String d2 = df1.format(date2); - builder = new StringBuilder(); - builder.append(d2); - builder.insert(builder.length() - 2, ':'); - d2 = builder.toString(); - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate LIKE TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate IN (TIMESTAMP '" + d0 + "' ,TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDate NOT IN (TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY test:singleDate ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY test:singleDate ", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleDate IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleDate NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), true); - - // d:date single by alias - - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias LIKE TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias IN (TIMESTAMP '" + d0 + "' ,TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), - false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE alias NOT IN (TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY alias ", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE ANY alias IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), true); - testQuery("SELECT test:singleDate as alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), true); - - // d:date multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate LIKE TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDate NOT IN (TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY test:multipleDate ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY test:multipleDate ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDate IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDate IN (TIMESTAMP '" + d2 + "', TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDate NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d1 + "')", 0, false, "cmis:name", new String(), - false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDate NOT IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 0, false, "cmis:name", new String(), - false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDate NOT IN (TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", new String(), false); - - // d:date multiple by alias - - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias LIKE TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), - true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE alias NOT IN (TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE ANY alias IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE ANY alias IN (TIMESTAMP '" + d2 + "', TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d1 + "')", 0, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 0, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDate alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", new String(), false); - - } - - public void test_d_datetime() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleDatetime"); - Date value = DefaultTypeConverter.INSTANCE.convert(Date.class, sValue); - assertEquals(date1, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleDatetime"); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleDatetime"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Date.class, sValue); - assertEquals(2, collection.size()); - Date[] members = new Date[2]; - members = collection.toArray(members); - assertEquals(date1, members[0]); - assertEquals(date2, members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleDatetime"); - assertEquals(CMISDataTypeEnum.DATETIME, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - SimpleDateFormat df1 = new SimpleDateFormat("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSSZ"); - - String d0 = df1.format(date0); - StringBuilder builder = new StringBuilder(); - builder.append(d0); - builder.insert(builder.length() - 2, ':'); - d0 = builder.toString(); - - String d1 = df1.format(date1); - builder = new StringBuilder(); - builder.append(d1); - builder.insert(builder.length() - 2, ':'); - d1 = builder.toString(); - - String d2 = df1.format(date2); - builder = new StringBuilder(); - builder.append(d2); - builder.insert(builder.length() - 2, ':'); - d2 = builder.toString(); - - // d:datetime single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime LIKE TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime IN (TIMESTAMP '" + d0 + "' ,TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleDatetime NOT IN (TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY test:singleDatetime ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY test:singleDatetime ", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleDatetime IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleDatetime NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), - true); - - // d:datetime single by alias - - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias LIKE TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias IN (TIMESTAMP '" + d0 + "' ,TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", - new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE alias NOT IN (TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY alias ", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE ANY alias IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), true); - testQuery("SELECT test:singleDatetime alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), true); - - // d:date multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime LIKE TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleDatetime NOT IN (TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY test:multipleDatetime ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY test:multipleDatetime ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDatetime IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", new String(), - false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDatetime IN (TIMESTAMP '" + d2 + "', TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", new String(), - false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDatetime NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d1 + "')", 0, false, "cmis:name", - new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDatetime NOT IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 0, false, "cmis:name", - new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleDatetime NOT IN (TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", new String(), false); - - // d:date multiple by alias - - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias = TIMESTAMP '" + d2 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias <> TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias < TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias <= TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d1 + "'", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias > TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d1 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias >= TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias LIKE TIMESTAMP '" + d0 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias NOT LIKE TIMESTAMP '" + d2 + "'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE alias NOT IN (TIMESTAMP '" + d1 + "')", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE TIMESTAMP '" + d1 + "' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE TIMESTAMP '" + d2 + "' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE ANY alias IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 1, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE ANY alias IN (TIMESTAMP '" + d2 + "', TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d0 + "', TIMESTAMP '" + d1 + "')", 0, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d1 + "', TIMESTAMP '" + d2 + "')", 0, false, "cmis:name", - new String(), false); - testQuery("SELECT test:multipleDatetime alias FROM test:extendedContent WHERE ANY alias NOT IN (TIMESTAMP '" + d0 + "')", 1, false, "cmis:name", new String(), false); - - } - - public void test_d_boolean() throws Exception - { - addTypeTestData(); - assertNotNull(dictionaryService.getType(extendedContent)); - assertNotNull(cmisDictionaryService.findTypeByQueryName("test:extendedContent")); - - testQuery("SELECT * FROM test:extendedContent", 1, false, "cmis:name", new String(), false); - - CMISQueryOptions options = new CMISQueryOptions("SELECT * FROM test:extendedContent", rootNodeRef.getStoreRef()); - options.setDefaultFTSConnective(Connective.OR); - options.setDefaultFTSFieldConnective(Connective.OR); - CMISResultSet rs = cmisQueryService.query(options); - assertEquals(1, rs.length()); - for (CMISResultSetRow row : rs) - { - Serializable sValue = row.getValue("test:singleBoolean"); - Boolean value = DefaultTypeConverter.INSTANCE.convert(Boolean.class, sValue); - assertEquals(Boolean.TRUE, value); - CMISResultSetColumn column = rs.getResultSetMetaData().getColumn("test:singleBoolean"); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.SINGLE_VALUED, column.getCMISPropertyDefinition().getCardinality()); - - sValue = row.getValue("test:multipleBoolean"); - assert (sValue instanceof Collection); - Collection collection = DefaultTypeConverter.INSTANCE.getCollection(Boolean.class, sValue); - assertEquals(2, collection.size()); - Boolean[] members = new Boolean[2]; - members = collection.toArray(members); - assertEquals(Boolean.TRUE, members[0]); - assertEquals(Boolean.FALSE, members[1]); - column = rs.getResultSetMetaData().getColumn("test:multipleBoolean"); - assertEquals(CMISDataTypeEnum.BOOLEAN, column.getCMISDataType()); - assertEquals(CMISCardinalityEnum.MULTI_VALUED, column.getCMISPropertyDefinition().getCardinality()); - } - rs.close(); - - // d:boolean single - - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean = TRUE", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean = true", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean = FALSE", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean = false", 0, false, "cmis:name", new String(), false); - // not strictly compliant... - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean = TRue", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean <> TRUE", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean <> FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean < TRUE", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean < FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean <= TRUE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean <= FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean > TRUE", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean > FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean >= TRUE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean >= FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean LIKE 'TRUE'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean NOT LIKE 'FALSE'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean IN (TRUE)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:singleBoolean NOT IN (FALSE)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE TRUE = ANY test:singleBoolean ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE FALSE = ANY test:singleBoolean ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleBoolean IN (TRUE)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:singleBoolean NOT IN (FALSE)", 1, false, "cmis:name", new String(), true); - - // d:boolean single by alias - - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias = TRUE", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias = true", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias = FALSE", 0, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias = false", 0, false, "cmis:name", new String(), false); - // not strictly compliant... - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias = TRue", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias <> TRUE", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias <> FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias < TRUE", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias < FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias <= TRUE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias <= FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias > TRUE", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias > FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias >= TRUE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias >= FALSE", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias LIKE 'TRUE'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias NOT LIKE 'FALSE'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias IN (TRUE)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE alias NOT IN (FALSE)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE TRUE = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE FALSE = ANY alias ", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE ANY alias IN (TRUE)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:singleBoolean alias FROM test:extendedContent WHERE ANY alias NOT IN (FALSE)", 1, false, "cmis:name", new String(), true); - - // d:boolean multiple - - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean = 2", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean <> 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean < 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean <= 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean > 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean >= 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE test:multipleBoolean NOT IN (2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE '1' = ANY test:multipleBoolean ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE '2' = ANY test:multipleBoolean ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleBoolean IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleBoolean IN (2, 3)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleBoolean NOT IN (1, 2)", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleBoolean NOT IN (2, 3)", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM test:extendedContent WHERE ANY test:multipleBoolean NOT IN (3, 4)", 1, false, "cmis:name", new String(), true); - - // d:boolean multiple by alias - - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias = 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias = 2", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias <> 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias <> 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias < 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias < 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias <= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias <= 2", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias > 1", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias > 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias >= 1", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias >= 0", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias LIKE '1'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias NOT LIKE '2'", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE alias NOT IN (2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE '1' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE '2' = ANY alias ", 1, false, "cmis:name", new String(), false); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE ANY alias IN (1, 2)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE ANY alias IN (2, 3)", 1, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE ANY alias NOT IN (1, 2)", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE ANY alias NOT IN (2, 3)", 0, false, "cmis:name", new String(), true); - testQuery("SELECT test:multipleBoolean as alias FROM test:extendedContent WHERE ANY alias NOT IN (3, 4)", 1, false, "cmis:name", new String(), true); - } - - public void testBasicContainsSyntax() throws Exception - { - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('one')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('-quick')", doc_count-1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick brown fox')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick one')", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick -one')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('-quick one')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('-quick -one')", doc_count-2, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('fox brown quick')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR one')", 2, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR -one')", doc_count-1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('-quick OR -one')", doc_count, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'quick brown fox\\'')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'fox brown quick\\'')", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'quick brown fox\\' one')", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('\\'quick brown fox\\' -one')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('-\\'quick brown fox\\' one')", 1, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('-\\'quick brown fox\\' -one')", doc_count-2, false, "cmis:name", new String(), false); - - // escaping - testExtendedQuery("SELECT * FROM cmis:folder WHERE CONTAINS('cmis:name:\\'Folder 9\\\\\\'\\'')", 1, false, "cmis:name", new String(), false); - - // precedence - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR brown one')", 1, false, "cmis:name", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR brown AND one')", 1, false, "cmis:name", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR (brown AND one)')", 1, false, "cmis:name", new String(), false); - testExtendedQuery("SELECT * FROM cmis:document WHERE CONTAINS('(quick OR brown) AND one')", 0, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR brown OR one')", 2, false, "cmis:name", new String(), false); - testQuery("SELECT * FROM cmis:document WHERE CONTAINS('quick OR brown one')", 1, false, "cmis:name", new String(), false); - } - - public void testOrderableProperties() - { - - addTypeSortTestData(); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleTextUntokenised").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:singleTextTokenised").isOrderable()); - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleTextBoth").isOrderable()); - - testOrderableProperty("test:singleTextUntokenised"); - testOrderablePropertyFail("test:singleTextTokenised"); - testOrderableProperty("test:singleTextBoth"); - - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleTextUntokenised").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleTextTokenised").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleTextBoth").isOrderable()); - - testOrderablePropertyFail("test:multipleTextUntokenised"); - testOrderablePropertyFail("test:multipleTextTokenised"); - testOrderablePropertyFail("test:multipleTextBoth"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleMLTextUntokenised").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:singleMLTextTokenised").isOrderable()); - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleMLTextBoth").isOrderable()); - - testOrderableProperty("test:singleMLTextUntokenised"); - testOrderablePropertyFail("test:singleMLTextTokenised"); - testOrderableProperty("test:singleMLTextBoth"); - - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleMLTextUntokenised").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleMLTextTokenised").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleMLTextBoth").isOrderable()); - - testOrderablePropertyFail("test:multipleMLTextUntokenised"); - testOrderablePropertyFail("test:multipleMLTextTokenised"); - testOrderablePropertyFail("test:multipleMLTextBoth"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleFloat").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleFloat").isOrderable()); - - testOrderableProperty("test:singleFloat"); - testOrderablePropertyFail("test:multipleFloat"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleDouble").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleDouble").isOrderable()); - - testOrderableProperty("test:singleDouble"); - testOrderablePropertyFail("test:multipleDouble"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleInteger").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleInteger").isOrderable()); - - testOrderableProperty("test:singleInteger"); - testOrderablePropertyFail("test:multipleInteger"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleLong").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleLong").isOrderable()); - - testOrderableProperty("test:singleLong"); - testOrderablePropertyFail("test:multipleLong"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleDate").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleDate").isOrderable()); - - testOrderableProperty("test:singleDate"); - testOrderablePropertyFail("test:multipleDate"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleDatetime").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleDatetime").isOrderable()); - - testOrderableProperty("test:singleDatetime"); - testOrderablePropertyFail("test:multipleDatetime"); - - assertTrue(cmisDictionaryService.findPropertyByQueryName("test:singleBoolean").isOrderable()); - assertFalse(cmisDictionaryService.findPropertyByQueryName("test:multipleBoolean").isOrderable()); - - testOrderableProperty("test:singleBoolean"); - testOrderablePropertyFail("test:multipleBoolean"); - } - - public void testNonQueryableTypes() throws Exception - { - testQuery("SELECT * FROM cmis:policy", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM cmis:relationship ", 0, false, "cmis:name", new String(), true); - testQuery("SELECT * FROM cm:ownable ", 0, false, "cmis:name", new String(), true); - testExtendedQuery("SELECT * FROM cm:ownable ", 1, false, "cmis:name", new String(), false); - } - - private void testOrderableProperty(String propertyQueryName) - { - testOrderBy("SELECT " + propertyQueryName + " FROM test:extendedContent ORDER BY " + propertyQueryName + " ASC", 13, false, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - propertyQueryName); - testOrderBy("SELECT " + propertyQueryName + " FROM test:extendedContent ORDER BY " + propertyQueryName + " DESC", 13, false, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - propertyQueryName); - testOrderBy("SELECT " + propertyQueryName + " FROM test:extendedContent ORDER BY " + propertyQueryName + " DESC", 13, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - propertyQueryName); - } - - private void testOrderablePropertyFail(String propertyQueryName) - { - testOrderBy("SELECT " + propertyQueryName + " FROM test:extendedContent ORDER BY " + propertyQueryName + " ASC", 13, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - propertyQueryName); - testOrderBy("SELECT " + propertyQueryName + " FROM test:extendedContent ORDER BY " + propertyQueryName + " DESC", 13, true, Order.DESCENDING, CMISQueryMode.CMS_STRICT, - propertyQueryName); - testOrderBy("SELECT " + propertyQueryName + " FROM test:extendedContent ORDER BY " + propertyQueryName + " DESC", 13, true, Order.ASCENDING, CMISQueryMode.CMS_STRICT, - propertyQueryName); - } - - private void addTypeTestDataModel() - { - // load in the test model - ClassLoader cl = BaseNodeServiceTest.class.getClassLoader(); - InputStream modelStream = cl.getResourceAsStream("org/alfresco/cmis/search/CMIS-query-test-model.xml"); - assertNotNull(modelStream); - M2Model model = M2Model.createModel(modelStream); - dictionaryDAO.putModel(model); - - ((CMISAbstractDictionaryService) cmisDictionaryService).afterDictionaryDestroy(); - ((CMISAbstractDictionaryService) cmisDictionaryService).afterDictionaryInit(); - - namespaceDao.addPrefix("test", "http://www.alfresco.org/test/cmis-query-test"); - } - - private void addTypeSortTestData() - { - addTypeTestDataModel(); - - addSortableNull(); - for (int i = 0; i < 10; i++) - { - addSortableNode(i); - if (i == 5) - { - addSortableNull(); - } - } - - addSortableNull(); - } - - private NodeRef addSortableNull() - { - Map properties = new HashMap(); - MLText ml = new MLText(); - ml.addValue(Locale.ENGLISH, "Test null"); - properties.put(ContentModel.PROP_DESCRIPTION, ml); - properties.put(ContentModel.PROP_TITLE, ml); - properties.put(ContentModel.PROP_NAME, "Test null"); - properties.put(ContentModel.PROP_CREATED, new Date()); - NodeRef c0 = nodeService.createNode(f0, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Test One", namespaceService), extendedContent, properties).getChildRef(); - return c0; - } - - private static String[] orderable = new String[] { "zero loons", "one banana", "two apples", "three fruit", "four lemurs", "five rats", "six badgers", "seven cards", - "eight cabbages", "nine zebras", "ten lemons" }; - - private NodeRef addSortableNode(int position) - { - Map properties = new HashMap(); - MLText ml = new MLText(); - ml.addValue(Locale.ENGLISH, "Test " + position); - properties.put(ContentModel.PROP_DESCRIPTION, ml); - properties.put(ContentModel.PROP_TITLE, ml); - properties.put(ContentModel.PROP_NAME, "Test " + position); - properties.put(ContentModel.PROP_CREATED, new Date()); - properties.put(singleTextUntokenised, orderable[position]); - properties.put(singleTextTokenised, orderable[position]); - properties.put(singleTextBoth, orderable[position]); - properties.put(multipleTextUntokenised, asArray(orderable[position], orderable[position + 1])); - properties.put(multipleTextTokenised, asArray(orderable[position], orderable[position + 1])); - properties.put(multipleTextBoth, asArray(orderable[position], orderable[position + 1])); - properties.put(singleMLTextUntokenised, makeMLText(position)); - properties.put(singleMLTextTokenised, makeMLText(position)); - properties.put(singleMLTextBoth, makeMLText(position)); - properties.put(multipleMLTextUntokenised, makeMLTextMVP(position)); - properties.put(multipleMLTextTokenised, makeMLTextMVP(position)); - properties.put(multipleMLTextBoth, makeMLTextMVP(position)); - properties.put(singleFloat, 1.1f * position); - properties.put(multipleFloat, asArray(1.1f * position, 2.2f * position)); - properties.put(singleDouble, 1.1d * position); - properties.put(multipleDouble, asArray(1.1d * position, 2.2d * position)); - properties.put(singleInteger, 1 * position); - properties.put(multipleInteger, asArray(1 * position, 2 * position)); - properties.put(singleLong, 1l * position); - properties.put(multipleLong, asArray(1l * position, 2l * position)); - GregorianCalendar cal = new GregorianCalendar(); - cal.setTime(new Date()); - cal.add(Calendar.DAY_OF_MONTH, position); - Date d1 = cal.getTime(); - cal.add(Calendar.DAY_OF_MONTH, -1); - // Date d0 = cal.getTime(); - cal.add(Calendar.DAY_OF_MONTH, 2); - Date d2 = cal.getTime(); - properties.put(singleDate, d1); - properties.put(multipleDate, asArray(d1, d2)); - properties.put(singleDatetime, d1); - properties.put(multipleDatetime, asArray(d1, d2)); - properties.put(singleBoolean, position % 2 == 0 ? true : false); - properties.put(multipleBoolean, asArray(true, false)); - NodeRef c0 = nodeService.createNode(f0, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Test One", namespaceService), extendedContent, properties).getChildRef(); - return c0; - } - - private NodeRef addTypeTestData() - { - addTypeTestDataModel(); - - I18NUtil.setLocale(Locale.UK); - - Map properties = new HashMap(); - MLText ml = new MLText(); - ml.addValue(Locale.ENGLISH, "Test one"); - ml.addValue(Locale.US, "Test 1"); - properties.put(ContentModel.PROP_DESCRIPTION, ml); - properties.put(ContentModel.PROP_TITLE, ml); - properties.put(ContentModel.PROP_NAME, "Test one"); - properties.put(ContentModel.PROP_CREATED, new Date()); - properties.put(singleTextUntokenised, "Un tokenised"); - properties.put(singleTextTokenised, "Un tokenised"); - properties.put(singleTextBoth, "Un tokenised"); - properties.put(multipleTextUntokenised, asArray("Un tokenised", "two parts")); - properties.put(multipleTextTokenised, asArray("Un tokenised", "two parts")); - properties.put(multipleTextBoth, asArray("Un tokenised", "two parts")); - properties.put(singleMLTextUntokenised, makeMLText()); - properties.put(singleMLTextTokenised, makeMLText()); - properties.put(singleMLTextBoth, makeMLText()); - properties.put(multipleMLTextUntokenised, makeMLTextMVP()); - properties.put(multipleMLTextTokenised, makeMLTextMVP()); - properties.put(multipleMLTextBoth, makeMLTextMVP()); - properties.put(singleFloat, 1f); - properties.put(multipleFloat, asArray(1f, 1.1f)); - properties.put(singleDouble, 1d); - properties.put(multipleDouble, asArray(1d, 1.1d)); - properties.put(singleInteger, 1); - properties.put(multipleInteger, asArray(1, 2)); - properties.put(singleLong, 1l); - properties.put(multipleLong, asArray(1l, 2l)); - date1 = new Date(); - GregorianCalendar cal = new GregorianCalendar(); - cal.setTime(date1); - cal.add(Calendar.DAY_OF_MONTH, -1); - date0 = cal.getTime(); - cal.add(Calendar.DAY_OF_MONTH, 2); - date2 = cal.getTime(); - properties.put(singleDate, date1); - properties.put(multipleDate, asArray(date1, date2)); - properties.put(singleDatetime, date1); - properties.put(multipleDatetime, asArray(date1, date2)); - properties.put(singleBoolean, true); - properties.put(multipleBoolean, asArray(true, false)); - NodeRef c0 = nodeService.createNode(f0, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", "Test One", namespaceService), extendedContent, properties).getChildRef(); - return c0; - } - - private static String[] mlOrderable_en = new String[] { "AAAA BBBB", "EEEE FFFF", "II", "KK", "MM", "OO", "QQ", "SS", "UU", "AA", "CC" }; - - private static String[] mlOrderable_fr = new String[] { "CCCC DDDD", "GGGG HHHH", "JJ", "LL", "NN", "PP", "RR", "TT", "VV", "BB", "DD" }; - - private MLText makeMLText() - { - return makeMLText(0); - } - - private MLText makeMLText(int position) - { - MLText ml = new MLText(); - ml.addValue(Locale.ENGLISH, mlOrderable_en[position]); - ml.addValue(Locale.FRENCH, mlOrderable_fr[position]); - return ml; - } - - private ArrayList makeMLTextMVP() - { - return makeMLTextMVP(0); - } - - private ArrayList makeMLTextMVP(int position) - { - MLText m1 = new MLText(); - m1.addValue(Locale.ENGLISH, mlOrderable_en[position]); - MLText m2 = new MLText(); - m2.addValue(Locale.FRENCH, mlOrderable_fr[position]); - ArrayList answer = new ArrayList(2); - answer.add(m1); - answer.add(m2); - return answer; - } - - private ArrayList asArray(T... ts) - { - ArrayList list = new ArrayList(ts.length); - for (T t : ts) - { - list.add(t); - } - return list; - } -} diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java index 5c980f3cef..16dbd6f42e 100644 --- a/source/test-java/org/alfresco/opencmis/CMISTest.java +++ b/source/test-java/org/alfresco/opencmis/CMISTest.java @@ -37,11 +37,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.alfresco.cmis.CMISAccessControlService; import org.alfresco.cmis.CMISChangeEvent; import org.alfresco.cmis.CMISChangeLog; import org.alfresco.cmis.CMISChangeLogService; -import org.alfresco.cmis.CMISDictionaryModel; import org.alfresco.model.ContentModel; import org.alfresco.opencmis.search.CMISQueryOptions; import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode; @@ -81,6 +79,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.Pair; +import org.apache.chemistry.opencmis.commons.BasicPermissions; import org.apache.chemistry.opencmis.commons.PropertyIds; import org.apache.chemistry.opencmis.commons.data.Ace; import org.apache.chemistry.opencmis.commons.data.AllowableActions; @@ -404,15 +403,15 @@ public class CMISTest PropertyData propIsLatestMajorVersion = null; for (PropertyData property : properties) { - if (property.getId().equals(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION)) + if (property.getId().equals(PropertyIds.IS_LATEST_MAJOR_VERSION)) { found = true; propIsLatestMajorVersion = property; break; } } - //properties..contains(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); - assertTrue("The CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION property was not found", found); + //properties..contains(PropertyIds.IS_LATEST_MAJOR_VERSION); + assertTrue("The PropertyIds.IS_LATEST_MAJOR_VERSION property was not found", found); if (found) { return propIsLatestMajorVersion; @@ -1667,7 +1666,7 @@ public class CMISTest PropertyData propIsLatestMajorVersion = null; for (PropertyData property : properties) { - if (property.getId().equals(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION)) + if (property.getId().equals(PropertyIds.IS_LATEST_MAJOR_VERSION)) { found = true; propIsLatestMajorVersion = property; @@ -2122,9 +2121,9 @@ public class CMISTest AccessControlEntryImpl ace = new AccessControlEntryImpl(); ace.setPrincipal(new AccessControlPrincipalDataImpl(testGroup)); List putPermissions = new ArrayList(); - putPermissions.add(CMISAccessControlService.CMIS_ALL_PERMISSION); - putPermissions.add(CMISAccessControlService.CMIS_READ_PERMISSION); - putPermissions.add(CMISAccessControlService.CMIS_WRITE_PERMISSION); + putPermissions.add(BasicPermissions.ALL); + putPermissions.add(BasicPermissions.READ); + putPermissions.add(BasicPermissions.WRITE); ace.setPermissions(putPermissions); ace.setDirect(true); acesList.add(ace); diff --git a/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java b/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java index b90eab41d0..fc22f0b4a7 100644 --- a/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java +++ b/source/test-java/org/alfresco/repo/rendition/MockedTestServiceRegistry.java @@ -22,10 +22,9 @@ import static org.mockito.Mockito.mock; import java.util.Collection; -import org.alfresco.cmis.CMISDictionaryService; -import org.alfresco.cmis.CMISQueryService; -import org.alfresco.cmis.CMISServices; import org.alfresco.mbeans.VirtServerRegistry; +import org.alfresco.opencmis.dictionary.CMISDictionaryService; +import org.alfresco.opencmis.search.CMISQueryService; import org.alfresco.repo.admin.SysAdminParams; import org.alfresco.repo.forms.FormService; import org.alfresco.repo.imap.ImapService; @@ -437,13 +436,6 @@ public class MockedTestServiceRegistry implements ServiceRegistry return null; } - @Override - public CMISServices getCMISService() - { - // A mock response - return null; - } - @Override public CMISQueryService getCMISQueryService() {