diff --git a/rm-server/build.gradle b/rm-server/build.gradle index d1654f7507..15fa2d4441 100644 --- a/rm-server/build.gradle +++ b/rm-server/build.gradle @@ -13,7 +13,7 @@ dependencies { testRuntime files(testResourceDir) alfrescoDeps group: alfrescoGroupId, name: 'alfresco', version: alfrescoBaseVersion, type: 'war' - alfrescoDeps group: alfrescoGroupId, name: 'alfresco-solr', version: alfrescoBaseVersion, type: 'zip' + alfrescoDeps group: alfrescoGroupId, name: 'alfresco-solr', version: alfrescoBaseSolrVersion, type: 'zip' } task fetchSOLR(type:Copy) { diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml index 188fd27c0b..53b74a19bc 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module-context.xml @@ -199,6 +199,7 @@ + - + + @@ -1514,6 +1515,9 @@ + + + @@ -1523,6 +1527,15 @@ + + + + + + + + ${authority.useBridgeTable} + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index 36935015bb..f605d8d10d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -68,6 +68,7 @@ class="org.alfresco.module.org_alfresco_module_rm.script.CustomReferenceDefinitionsGet" parent="webscript"> + @@ -89,6 +90,7 @@ class="org.alfresco.module.org_alfresco_module_rm.script.CustomRefsGet" parent="rmBaseWebscript"> + @@ -155,6 +157,7 @@ parent="webscript"> + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties index 6c31c3c9f2..1f9a71715e 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/security/rm-method-security.properties @@ -1,181 +1,184 @@ ## # RM Method security for Alfresco code services # -# Note: add alfresco/extension/rm-method-security.properties to extend +# Note: add alfresco/extension/rm-method-security.properties to extend ## ## Node Service -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStores=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createStore=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStores=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createStore=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.exists=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeStatus=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeStatus=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAllRootNodes=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getRootNode=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getRootNode=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createNode=RM.Create.0.3 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.moveNode=RM.Move.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setChildAssociationIndex=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.moveNode=RM.Move.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setChildAssociationIndex=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getType=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setType=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addAspect=RM.Update.0.1.2 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setType=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addAspect=RM.Update.0.1.2 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAspect=RM.Update.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.hasAspect=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAspects=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.hasAspect=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAspects=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.deleteNode=RM.Delete.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addChild=RM.Create.0.1.2 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChild=RM.Delete.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChildAssociation=RM.Delete.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeChildAssociation=RM.Delete.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperties=RM.Read.0,AFTER_RM.FilterProperty -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperty=RM.Read.0,RM.ReadProperty.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getProperty=RM.Read.0,RM.ReadProperty.0.1 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setProperties=RM.UpdateProperties.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addProperties=RM.UpdateProperties.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.addProperties=RM.UpdateProperties.0.1 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.setProperty=RM.UpdateProperties.0.1.2 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeProperty=RM.UpdateProperties.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeProperty=RM.UpdateProperties.0.1 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getParentAssocs=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocs=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocs=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildByName=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildrenByName=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildrenByName=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPrimaryParent=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createAssociation=RM.Assoc.0.1 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAssociation=Assoc.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.createAssociation=RM.Assoc.0.1 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.removeAssociation=Assoc.0.1 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getTargetAssocs=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getSourceAssocs=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getAssoc=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPath=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPath=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getPaths=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStoreArchiveNode=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getStoreArchiveNode=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.restoreNode=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsWithoutParentAssocsOfType=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getNodeRef=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsByPropertyValue=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.getChildAssocsByPropertyValue=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.countChildAssocs=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.repository.NodeService.*=RM_DENY ## File Folder Service -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.list=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.list=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listFiles=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listFolders=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listDeepFolders=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.listDeepFolders=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getLocalizedSibling=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.search=RM.Read.0,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.searchSimple=RM.Read.0,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.searchSimple=RM.Read.0,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.rename=RM.Update.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.move=RM.Move.0.1 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.moveFrom=RM.Move.0.2 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.move=RM.Move.0.1 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.moveFrom=RM.Move.0.2 rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.copy=RM.Read.0,RM.Create.1.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.create=RM.Create.0.2 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.delete=RM.Delete.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getNamePath=RM.Read.1 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.resolveNamePath=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.create=RM.Create.0.2 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.delete=RM.Delete.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getNamePath=RM.Read.1 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getNameOnlyPath=RM.Read.1 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.resolveNamePath=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getFileInfo=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getReader=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getWriter=RM.WriteContent.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getReader=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getWriter=RM.WriteContent.0 rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.exists=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getType=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.getType=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.isHidden=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.setHidden=RM.Update.0 +rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.*=RM_DENY ## Content Service rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getStoreTotalSpace=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getStoreFreeSpace=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getRawReader=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getReader=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getRawReader=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getReader=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getWriter=RM.WriteContent.0 -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.isTransformable=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTransformer=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.isTransformable=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTransformer=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getMaxSourceSizeBytes=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getImageTransformer=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getImageTransformer=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.transform=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTempWriter=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.getTempWriter=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.repository.ContentService.*=RM_DENY ## Search Service -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.query=RM_QUERY,AFTER_RM.FilterNode -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectNodes=RM_QUERY,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.query=RM_QUERY,AFTER_RM.FilterNode +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectNodes=RM_QUERY,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.selectProperties=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.contains=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.like=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.contains=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.like=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.search.SearchService.*=RM_DENY ## Category Service -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getChildren=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getCategories=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getChildren=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getCategories=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassifications=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getRootCategories=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassificationAspects=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getRootCategories=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getClassificationAspects=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createClassification=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createRootCategory=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createCategory=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteClassification=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createRootCategory=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.createCategory=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteClassification=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.deleteCategory=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getTopCategories=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.getTopCategories=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.search.CategoryService.*=RM_DENY ## Lock Service -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.lock=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.unlock=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockStatus=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockType=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.checkForLock=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLocks=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.lock=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.unlock=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockStatus=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLockType=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.checkForLock=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.getLocks=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.lock.LockService.*=RM_DENY ## Multilingual Content Service -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationContainer=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslations=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationForLocale=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationForLocale=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getMissingTranslations=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getPivotTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.getPivotTranslation=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.isTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.makeTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.makeTranslation=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.unmakeTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addTranslation=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addTranslation=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.addEmptyTranslation=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.copyTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.copyTranslationContainer=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.moveTranslationContainer=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.deleteTranslationContainer=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.deleteTranslationContainer=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.MultilingualContentService.*=RM_DENY ## Edition Service - -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.createEdition=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getEditions=RM_ABSTAIN + +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.createEdition=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getEditions=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedTranslations=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedMetadatas=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.*=RM_DENY - -## Check Out Check In Service - +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.getVersionedMetadatas=RM_ABSTAIN +rm.methodsecurity.org.alfresco.service.cmr.ml.EditionService.*=RM_DENY + +## Check Out Check In Service + rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.checkout=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.checkin=RM_ABSTAIN rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.cancelCheckout=RM_ABSTAIN -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getWorkingCopy=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getCheckedOut=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isWorkingCopy=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isCheckedOut=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.*=RM_DENY - -## Permission Service - -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllAuthorities=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getWorkingCopy=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.getCheckedOut=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isWorkingCopy=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.isCheckedOut=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.coci.CheckOutCheckInService.*=RM_DENY + +## Permission Service + +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllAuthorities=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllPermission=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getPermissions=RM.Read.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getPermissions=RM.Read.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getAllSetPermissions=RM.Read.0 rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getSettablePermissions=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.hasPermission=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermissions=RM.Capability.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.hasPermission=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermissions=RM.Capability.0 rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.deletePermission=RM.Capability.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setPermission=RM.Capability.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setPermission=RM.Capability.0 rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.setInheritParentPermissions=RM.Capability.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=RM_ALLOW -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.clearPermission=RM.Capability.0 -rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.*=RM_DENY +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.getInheritParentPermissions=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.clearPermission=RM.Capability.0 +rm.methodsecurity.org.alfresco.service.cmr.security.PermissionService.*=RM_DENY ## Rule Service @@ -213,6 +216,7 @@ rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.deleteSite=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.findSites=RM_ALLOW,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getContainer=RM_ALLOW,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getMembersRole=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getMembersRoleInfo=ACL_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSite=RM_ALLOW,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteGroup=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoleGroup=RM_ALLOW @@ -222,6 +226,7 @@ rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasContainer=RM_ALLO rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.hasCreateSitePermissions=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.isMember=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembers=RM_ALLOW +rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listMembersInfo=ACL_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.listSites=RM_ALLOW,AFTER_RM.FilterNode rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.removeMembership=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.setMembership=RM_ALLOW diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminServiceImpl.java index f786cb9ff5..06ca2959d3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/RecordsManagementAdminServiceImpl.java @@ -89,10 +89,10 @@ import org.springframework.extensions.surf.util.URLDecoder; /** * Records Management AdminService Implementation. - * + * * @author Neil McErlean, janv */ -public class RecordsManagementAdminServiceImpl implements RecordsManagementAdminService, +public class RecordsManagementAdminServiceImpl implements RecordsManagementAdminService, RecordsManagementCustomModel, NodeServicePolicies.OnAddAspectPolicy, NodeServicePolicies.OnRemoveAspectPolicy, @@ -100,7 +100,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { /** Logger */ private static Log logger = LogFactory.getLog(RecordsManagementAdminServiceImpl.class); - + /** I18N messages*/ private static final String MSG_SERVICE_NOT_INIT = "rm.admin.service-not-init"; private static final String MSG_PROP_EXIST = "rm.admin.prop-exist"; @@ -119,26 +119,26 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin private static final String MSG_ERROR_WRITE_CUSTOM_MODEL = "rm.admin.error-write-custom-model"; private static final String MSG_ERROR_CLIENT_ID = "rm.admin.error-client-id"; private static final String MSG_ERROR_SPLIT_ID = "rm.admin.error-split-id"; - + /** Constants */ - public static final String RMC_CUSTOM_ASSOCS = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customAssocs"; - private static final String CUSTOM_CONSTRAINT_TYPE = org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.class.getName(); - private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "records_management_custom_model"); + public static final String RMC_CUSTOM_ASSOCS = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customAssocs"; + private static final String CUSTOM_CONSTRAINT_TYPE = org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.class.getName(); + private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "records_management_custom_model"); private static final String PARAM_ALLOWED_VALUES = "allowedValues"; private static final String PARAM_CASE_SENSITIVE = "caseSensitive"; - private static final String PARAM_MATCH_LOGIC = "matchLogic"; - public static final String RMA_RECORD = "rma:record"; + private static final String PARAM_MATCH_LOGIC = "matchLogic"; + public static final String RMA_RECORD = "rma:record"; private static final String SOURCE_TARGET_ID_SEPARATOR = "__"; - + /** Dictionary service */ private DictionaryService dictionaryService; - - /** Namespace service */ + + /** Namespace service */ private NamespaceService namespaceService; - + /** Node service */ private NodeService nodeService; - + /** Content service */ private ContentService contentService; @@ -147,17 +147,17 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin /** Policy component */ private PolicyComponent policyComponent; - + /** Policy delegates */ private ClassPolicyDelegate beforeCreateReferenceDelegate; - private ClassPolicyDelegate onCreateReferenceDelegate; + private ClassPolicyDelegate onCreateReferenceDelegate; private ClassPolicyDelegate beforeRemoveReferenceDelegate; private ClassPolicyDelegate onRemoveReferenceDelegate; - + /** List of types that can be customisable */ private List pendingCustomisableTypes; private Map customisableTypes; - + /** * @param dictionaryService the dictionary service */ @@ -181,7 +181,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { this.nodeService = nodeService; } - + /** * @param contentService the content service */ @@ -189,7 +189,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { this.contentService = contentService; } - + /** * @param policyComponent the policy component */ @@ -197,17 +197,17 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { this.policyComponent = policyComponent; } - + /** * Bootstrap for standard (non-RMC) dynamic models - * + * * @param dictonaryRepositoryBootstrap dictionary repository bootstrap */ public void setDictionaryRepositoryBootstrap(DictionaryRepositoryBootstrap dictonaryRepositoryBootstrap) { this.dictonaryRepositoryBootstrap = dictonaryRepositoryBootstrap; - } - + } + /** * Initialisation method */ @@ -219,7 +219,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin beforeRemoveReferenceDelegate = policyComponent.registerClassPolicy(BeforeRemoveReference.class); onRemoveReferenceDelegate = policyComponent.registerClassPolicy(OnRemoveReference.class); } - + protected void invokeBeforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) { // get qnames to invoke against @@ -228,7 +228,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin BeforeCreateReference policy = beforeCreateReferenceDelegate.get(qnames); policy.beforeCreateReference(fromNodeRef, toNodeRef, reference); } - + protected void invokeOnCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) { // get qnames to invoke against @@ -237,7 +237,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin OnCreateReference policy = onCreateReferenceDelegate.get(qnames); policy.onCreateReference(fromNodeRef, toNodeRef, reference); } - + protected void invokeBeforeRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) { // get qnames to invoke against @@ -246,9 +246,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin BeforeRemoveReference policy = beforeRemoveReferenceDelegate.get(qnames); policy.beforeRemoveReference(fromNodeRef, toNodeRef, reference); } - + /** - * + * * @param fromNodeRef * @param toNodeRef * @param reference @@ -279,7 +279,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin QName customPropertyAspect = getCustomAspect(aspectTypeQName); nodeService.addAspect(nodeRef, customPropertyAspect, null); } - + return null; } }, AuthenticationUtil.getSystemUserName()); @@ -300,9 +300,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin isCustomisable(aspectTypeQName) == true) { QName customPropertyAspect = getCustomAspect(aspectTypeQName); - nodeService.removeAspect(nodeRef, customPropertyAspect); + nodeService.removeAspect(nodeRef, customPropertyAspect); } - + return null; } }, AuthenticationUtil.getSystemUserName()); @@ -310,7 +310,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin /** * Make sure any custom property aspects are applied to newly created nodes. - * + * * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef) */ @Override @@ -328,9 +328,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin if (isCustomisable(type) == true) { QName customPropertyAspect = getCustomAspect(type); - nodeService.addAspect(nodeRef, customPropertyAspect, null); + nodeService.addAspect(nodeRef, customPropertyAspect, null); } - + TypeDefinition def = dictionaryService.getType(type); if (def != null) { @@ -340,56 +340,56 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { type = null; } - } - + } + return null; - } - }, AuthenticationUtil.getSystemUserName()); + } + }, AuthenticationUtil.getSystemUserName()); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#initialiseCustomModel() */ public void initialiseCustomModel() - { + { // Bind class behaviours policyComponent.bindClassBehaviour( - NodeServicePolicies.OnAddAspectPolicy.QNAME, - this, + NodeServicePolicies.OnAddAspectPolicy.QNAME, + this, new JavaBehaviour(this, "onAddAspect", NotificationFrequency.FIRST_EVENT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnRemoveAspectPolicy.QNAME, - this, + NodeServicePolicies.OnRemoveAspectPolicy.QNAME, + this, new JavaBehaviour(this, "onRemoveAspect", NotificationFrequency.FIRST_EVENT)); policyComponent.bindClassBehaviour( - NodeServicePolicies.OnCreateNodePolicy.QNAME, - this, + NodeServicePolicies.OnCreateNodePolicy.QNAME, + this, new JavaBehaviour(this, "onCreateNode", NotificationFrequency.FIRST_EVENT)); - + // Initialise the map getCustomisableMap(); } - + /** * @param customisableTypes list of string representations of the type qnames that are customisable */ public void setCustomisableTypes(List customisableTypes) { pendingCustomisableTypes = new ArrayList(); - for (String customisableType : customisableTypes) + for (String customisableType : customisableTypes) { pendingCustomisableTypes.add(QName.createQName(customisableType, namespaceService)); } } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomisable() */ public Set getCustomisable() { - return getCustomisableMap().keySet(); + return getCustomisableMap().keySet(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#getCustomisable(org.alfresco.service.cmr.repository.NodeRef) */ @@ -397,7 +397,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin public Set getCustomisable(NodeRef nodeRef) { Set result = new HashSet(5); - + // Check the nodes hierarchy for customisable types QName type = nodeService.getType(nodeRef); while (type != null && ContentModel.TYPE_CMOBJECT.equals(type) == false) @@ -405,9 +405,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin // Add to the list if the type is customisable if (isCustomisable(type) == true) { - result.add(type); + result.add(type); } - + // Type and get the types parent TypeDefinition def = dictionaryService.getType(type); if (def != null) @@ -419,7 +419,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin type = null; } } - + // Get all the nodes aspects Set aspects = nodeService.getAspects(nodeRef); for (QName aspect : aspects) @@ -432,7 +432,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { result.add(tempAspect); } - + // Try and get the parent aspect AspectDefinition aspectDef = dictionaryService.getAspect(tempAspect); if (aspectDef != null) @@ -445,13 +445,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } } } - + return result; } - + /** * Gets a map containing all the customisable types - * + * * @return map from the customisable type to its custom aspect */ private Map getCustomisableMap() @@ -460,7 +460,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { customisableTypes = new HashMap(7); Collection aspects = dictionaryService.getAspects(RM_CUSTOM_MODEL); - for (QName aspect : aspects) + for (QName aspect : aspects) { AspectDefinition aspectDef = dictionaryService.getAspect(aspect); String name = aspectDef.getName().getLocalName(); @@ -478,14 +478,14 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin else if (CompatibilityModel.NAME_CUSTOM_RECORD_FOLDER_PROPERTIES.equals(name) == true) { type = RecordsManagementModel.TYPE_RECORD_FOLDER; - } + } else if (CompatibilityModel.NAME_CUSTOM_RECORD_CATEGORY_PROPERTIES.equals(name) == true) { type = RecordsManagementModel.TYPE_RECORD_CATEGORY; } else if (CompatibilityModel.NAME_CUSTOM_RECORD_SERIES_PROPERTIES.equals(name) == true) { - // Only add the deprecated record series type as customisable if + // Only add the deprecated record series type as customisable if // a v1.0 installation has added custom properties if (aspectDef.getProperties().size() != 0) { @@ -497,12 +497,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { type = QName.createQName(prefixString, namespaceService); } - + // Add the customisable type to the map if (type != null) { customisableTypes.put(type, aspect); - + // Remove customisable type from the pending list if (pendingCustomisableTypes != null && pendingCustomisableTypes.contains(type) == true) { @@ -511,25 +511,25 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } } } - + // Deal with any pending types left over if (pendingCustomisableTypes != null && pendingCustomisableTypes.size() != 0) { NodeRef modelRef = getCustomModelRef(RecordsManagementModel.RM_CUSTOM_URI); M2Model model = readCustomContentModel(modelRef); try - { - for (QName customisableType : pendingCustomisableTypes) + { + for (QName customisableType : pendingCustomisableTypes) { QName customAspect = getCustomAspectImpl(customisableType); - + // Create the new aspect to hold the custom properties M2Aspect aspect = model.createAspect(customAspect.toPrefixString(namespaceService)); aspect.setDescription(customisableType.toPrefixString(namespaceService)); - - // Make a record of the customisable type + + // Make a record of the customisable type customisableTypes.put(customisableType, customAspect); - } + } } finally { @@ -537,13 +537,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } } } - return customisableTypes; - } + return customisableTypes; + } /** * Gets the QName of the custom aspect given the customisable type QName - * - * @param customisableType + * + * @param customisableType * @return */ private QName getCustomAspect(QName customisableType) @@ -556,10 +556,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } return result; } - + /** * Builds a custom aspect QName from a customisable type/aspect QName - * + * * @param customisableType * @return */ @@ -569,32 +569,32 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin localName = MessageFormat.format("{0}CustomProperties", localName); return QName.createQName(RM_CUSTOM_URI, localName); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#isCustomisable(org.alfresco.service.namespace.QName) */ @Override - public boolean isCustomisable(QName type) + public boolean isCustomisable(QName type) { - ParameterCheck.mandatory("type", type); + ParameterCheck.mandatory("type", type); return getCustomisable().contains(type); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#makeCustomisable(org.alfresco.service.namespace.QName) */ @Override - public void makeCustomisable(QName type) + public void makeCustomisable(QName type) { ParameterCheck.mandatory("type", type); - + if (customisableTypes == null) { // Add the type to the pending list pendingCustomisableTypes.add(type); } else - { + { QName customAspect = getCustomAspect(type); if (dictionaryService.getAspect(customAspect) == null) { @@ -614,25 +614,25 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } } } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#unmakeCustomisable(org.alfresco.service.namespace.QName) */ @Override - public void unmakeCustomisable(QName type) + public void unmakeCustomisable(QName type) { ParameterCheck.mandatory("type", type); - + if (customisableTypes == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_SERVICE_NOT_INIT)); } - + QName customAspect = getCustomAspect(type); if (dictionaryService.getAspect(customAspect) != null) { // TODO need to confirm that the custom properties are not being used! - + NodeRef modelRef = getCustomModelRef(customAspect.getNamespaceURI()); M2Model model = readCustomContentModel(modelRef); try @@ -652,10 +652,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#existsCustomProperty(org.alfresco.service.namespace.QName) */ @Override - public boolean existsCustomProperty(QName propertyName) + public boolean existsCustomProperty(QName propertyName) { ParameterCheck.mandatory("propertyName", propertyName); - + boolean result = false; if (RM_CUSTOM_URI.equals(propertyName.getNamespaceURI()) == true && dictionaryService.getProperty(propertyName) != null) @@ -671,7 +671,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin public Map getCustomPropertyDefinitions() { Map result = new HashMap(); - for (QName customisableType : getCustomisable()) + for (QName customisableType : getCustomisable()) { Map props = getCustomPropertyDefinitions(customisableType); if (props != null) @@ -697,102 +697,102 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin return propDefns; } - + /** - * @throws CustomMetadataException + * @throws CustomMetadataException * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.namespace.QName, java.lang.String, java.lang.String) */ public QName addCustomPropertyDefinition(QName propId, QName aspectName, String label, QName dataType, String title, String description) throws CustomMetadataException { return addCustomPropertyDefinition(propId, aspectName, label, dataType, title, description, null, false, false, false, null); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomPropertyDefinition(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.namespace.QName, java.lang.String, java.lang.String, java.lang.String, boolean, boolean, boolean, org.alfresco.service.namespace.QName) */ public QName addCustomPropertyDefinition(QName propId, - QName aspectName, - String label, - QName dataType, - String title, - String description, - String defaultValue, - boolean multiValued, - boolean mandatory, - boolean isProtected, + QName aspectName, + String label, + QName dataType, + String title, + String description, + String defaultValue, + boolean multiValued, + boolean mandatory, + boolean isProtected, QName lovConstraint) throws CustomMetadataException { if (isCustomisable(aspectName) == false) { throw new NotCustomisableMetadataException(aspectName.toPrefixString(namespaceService)); } - + // title parameter is currently ignored. Intentionally. if (propId == null) { // Generate a propId propId = this.generateQNameFor(label); } - + ParameterCheck.mandatory("aspectName", aspectName); ParameterCheck.mandatory("label", label); ParameterCheck.mandatory("dataType", dataType); - + NodeRef modelRef = getCustomModelRef(propId.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + QName customAspect = getCustomAspect(aspectName); M2Aspect customPropsAspect = deserializedModel.getAspect(customAspect.toPrefixString(namespaceService)); - + if (customPropsAspect == null) { throw new InvalidCustomAspectMetadataException(customAspect, aspectName.toPrefixString(namespaceService)); } - + String propIdAsString = propId.toPrefixString(namespaceService); M2Property customProp = customPropsAspect.getProperty(propIdAsString); if (customProp != null) { throw new PropertyAlreadyExistsMetadataException(propIdAsString); } - + M2Property newProp = customPropsAspect.createProperty(propIdAsString); newProp.setName(propIdAsString); newProp.setType(dataType.toPrefixString(namespaceService)); - + // Note that the title is used to store the RM 'label'. newProp.setTitle(label); newProp.setDescription(description); newProp.setDefaultValue(defaultValue); - + newProp.setMandatory(mandatory); newProp.setProtected(isProtected); newProp.setMultiValued(multiValued); - + newProp.setIndexed(true); newProp.setIndexedAtomically(true); newProp.setStoredInIndex(false); newProp.setIndexTokenisationMode(IndexTokenisationMode.FALSE); - + if (lovConstraint != null) { if (! dataType.equals(DataTypeDefinition.TEXT)) { throw new CannotApplyConstraintMetadataException(lovConstraint, propIdAsString, dataType); } - + String lovConstraintQNameAsString = lovConstraint.toPrefixString(namespaceService); newProp.addConstraintRef(lovConstraintQNameAsString); } - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("addCustomPropertyDefinition: "+label+ "=" + propIdAsString + " to aspect: "+aspectName); } - + return propId; } @@ -802,15 +802,15 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin public QName updateCustomPropertyDefinitionName(QName propQName, String newName) throws CustomMetadataException { ParameterCheck.mandatory("propQName", propQName); - + PropertyDefinition propDefn = dictionaryService.getProperty(propQName); if (propDefn == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); } - + if (newName == null) return propQName; - + QName newPropQName = getQNameForClientId(newName); if (newPropQName != null) { @@ -822,72 +822,72 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin throw new PropertyAlreadyExistsMetadataException(propIdAsString); } } - + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + M2Property targetProperty = findProperty(propQName, deserializedModel); targetProperty.setName(new StringBuilder().append(RecordsManagementCustomModel.RM_CUSTOM_PREFIX).append(QName.NAMESPACE_PREFIX).append(newName).toString()); targetProperty.setTitle(URLDecoder.decode(newName)); writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("setCustomPropertyDefinitionLabel: "+propQName+ "=" + newName); } - + return propQName; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionLabel(org.alfresco.service.namespace.QName, java.lang.String) */ public QName setCustomPropertyDefinitionLabel(QName propQName, String newLabel) { ParameterCheck.mandatory("propQName", propQName); - + PropertyDefinition propDefn = dictionaryService.getProperty(propQName); if (propDefn == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); } - + if (newLabel == null) return propQName; NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + M2Property targetProperty = findProperty(propQName, deserializedModel); targetProperty.setTitle(newLabel); writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("setCustomPropertyDefinitionLabel: "+propQName+ "=" + newLabel); } - + return propQName; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#setCustomPropertyDefinitionConstraint(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName) */ public QName setCustomPropertyDefinitionConstraint(QName propQName, QName newLovConstraint) { ParameterCheck.mandatory("propQName", propQName); - + PropertyDefinition propDefn = dictionaryService.getProperty(propQName); if (propDefn == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); } - + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + M2Property targetProp = findProperty(propQName, deserializedModel); String dataType = targetProp.getType(); @@ -897,10 +897,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin throw new AlfrescoRuntimeException(I18NUtil.getMessage(CannotApplyConstraintMetadataException.MSG_CANNOT_APPLY_CONSTRAINT, newLovConstraint, targetProp.getName(), dataType)); } String lovConstraintQNameAsString = newLovConstraint.toPrefixString(namespaceService); - + // Add the constraint - if it isn't already there. String refOfExistingConstraint = null; - + for (M2Constraint c : targetProp.getConstraints()) { // There should only be one constraint. @@ -912,14 +912,14 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin targetProp.removeConstraintRef(refOfExistingConstraint); } targetProp.addConstraintRef(lovConstraintQNameAsString); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("addCustomPropertyDefinitionConstraint: "+lovConstraintQNameAsString); } - + return propQName; } @@ -929,36 +929,36 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin public QName removeCustomPropertyDefinitionConstraints(QName propQName) { ParameterCheck.mandatory("propQName", propQName); - + PropertyDefinition propDefn = dictionaryService.getProperty(propQName); if (propDefn == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); } - + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + M2Property targetProperty = findProperty(propQName, deserializedModel); - + // Need to count backwards to remove constraints for (int i = targetProperty.getConstraints().size() - 1; i >= 0; i--) { String ref = targetProperty.getConstraints().get(i).getRef(); targetProperty.removeConstraintRef(ref); } - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("removeCustomPropertyDefinitionConstraints: "+propQName); } - + return propQName; } /** - * + * * @param propQName * @param deserializedModel * @return @@ -986,28 +986,28 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin public void removeCustomPropertyDefinition(QName propQName) { ParameterCheck.mandatory("propQName", propQName); - + NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + String propQNameAsString = propQName.toPrefixString(namespaceService); - + String aspectName = null; - + boolean found = false; - + // Need to select the correct aspect in the customModel from which we'll // attempt to delete the property definition. for (QName customisableType : getCustomisable()) { aspectName = getCustomAspect(customisableType).toPrefixString(namespaceService); M2Aspect customPropsAspect = deserializedModel.getAspect(aspectName); - + if (customPropsAspect == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNKNOWN_ASPECT, aspectName)); } - + M2Property prop = customPropsAspect.getProperty(propQNameAsString); if (prop != null) { @@ -1018,20 +1018,20 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin msg.append(propQNameAsString); logger.debug(msg.toString()); } - + found = true; customPropsAspect.removeProperty(propQNameAsString); break; } } - + if (found == false) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQNameAsString)); } - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("deleteCustomPropertyDefinition: "+propQNameAsString+" from aspect: "+aspectName); @@ -1045,10 +1045,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { AspectDefinition aspectDefn = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS); Map assocDefns = aspectDefn.getAssociations(); - + return assocDefns; } - + /** * @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService#addCustomReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName) */ @@ -1097,7 +1097,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin // Invoke before create reference policy invokeBeforeCreateReference(fromNode, toNode, refId); - + if (assocDef.isChild()) { this.nodeService.addChild(fromNode, toNode, refId, refId); @@ -1106,12 +1106,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { this.nodeService.createAssociation(fromNode, toNode, refId); } - + // Invoke on create reference policy invokeOnCreateReference(fromNode, toNode, refId); } - public void removeCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId) + public void removeCustomReference(NodeRef fromNode, NodeRef toNode, QName assocId) { Map availableAssocs = this.getCustomReferenceDefinitions(); @@ -1120,7 +1120,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { throw new IllegalArgumentException(I18NUtil.getMessage(MSG_REF_EXIST, assocId)); } - + invokeBeforeRemoveReference(fromNode, toNode, assocId); if (assocDef.isChild()) @@ -1141,7 +1141,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { nodeService.removeAssociation(fromNode, toNode, assocId); } - + invokeOnRemoveReference(fromNode, toNode, assocId); } @@ -1156,7 +1156,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin List childAssocs = nodeService.getChildAssocs(node); return childAssocs; } - + public List getCustomReferencesTo(NodeRef node) { List retrievedAssocs = nodeService.getSourceAssocs(node, RegexQNamePattern.MATCH_ALL); @@ -1168,7 +1168,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin List result = nodeService.getParentAssocs(node); return result; } - + // note: currently RMC custom assocs only public QName addCustomAssocDefinition(String label) { @@ -1179,14 +1179,14 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { throw new IllegalArgumentException(I18NUtil.getMessage(MSG_REF_LABEL_IN_USE, label)); } - + NodeRef modelRef = getCustomModelRef(""); // defaults to RM_CUSTOM_URI M2Model deserializedModel = readCustomContentModel(modelRef); - + String aspectName = RecordsManagementAdminServiceImpl.RMC_CUSTOM_ASSOCS; - + M2Aspect customAssocsAspect = deserializedModel.getAspect(aspectName); - + if (customAssocsAspect == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNKNOWN_ASPECT, aspectName)); @@ -1194,13 +1194,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin QName generatedQName = this.generateQNameFor(label); String generatedShortQName = generatedQName.toPrefixString(namespaceService); - + M2ClassAssociation customAssoc = customAssocsAspect.getAssociation(generatedShortQName); if (customAssoc != null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_ASSOC_EXISTS, generatedShortQName)); } - + M2Association newAssoc = customAssocsAspect.createAssociation(generatedShortQName); newAssoc.setSourceMandatory(false); newAssoc.setTargetMandatory(false); @@ -1211,17 +1211,17 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin // The label is stored in the title. newAssoc.setTitle(label); - + // TODO Could be the customAssocs aspect newAssoc.setTargetClassName(RecordsManagementAdminServiceImpl.RMA_RECORD); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("addCustomAssocDefinition: ("+label+")"); } - + return generatedQName; } @@ -1229,20 +1229,20 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { for (AssociationDefinition associationDefinition : getCustomReferenceDefinitions().values()) { - if (associationDefinition.getTitle().equalsIgnoreCase(label)) + if (associationDefinition.getTitle(dictionaryService).equalsIgnoreCase(label)) { return true; } } return false; } - + // note: currently RMC custom assocs only public QName addCustomChildAssocDefinition(String source, String target) { ParameterCheck.mandatoryString("source", source); ParameterCheck.mandatoryString("target", target); - + String compoundID = this.getCompoundIdFor(source, target); if (existsLabel(compoundID)) { @@ -1251,11 +1251,11 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin NodeRef modelRef = getCustomModelRef(""); // defaults to RM_CUSTOM_URI M2Model deserializedModel = readCustomContentModel(modelRef); - + String aspectName = RecordsManagementAdminServiceImpl.RMC_CUSTOM_ASSOCS; - + M2Aspect customAssocsAspect = deserializedModel.getAspect(aspectName); - + if (customAssocsAspect == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNKNOWN_ASPECT, aspectName)); @@ -1267,31 +1267,31 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CHILD_ASSOC_EXISTS, compoundID)); } QName generatedQName = this.generateQNameFor(compoundID); - + M2ChildAssociation newAssoc = customAssocsAspect.createChildAssociation(generatedQName.toPrefixString(namespaceService)); newAssoc.setSourceMandatory(false); newAssoc.setTargetMandatory(false); - + // MOB-1573 newAssoc.setSourceMany(true); newAssoc.setTargetMany(true); // source and target are stored in title. newAssoc.setTitle(compoundID); - + // TODO Could be the custom assocs aspect newAssoc.setTargetClassName(RecordsManagementAdminServiceImpl.RMA_RECORD); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("addCustomChildAssocDefinition: ("+source+","+target+")"); } - + return generatedQName; } - + // note: currently RMC custom assocs only public QName updateCustomChildAssocDefinition(QName refQName, String newSource, String newTarget) { @@ -1303,7 +1303,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } return persistUpdatedAssocTitle(refQName, compoundId); } - + // note: currently RMC custom assocs only public QName updateCustomAssocDefinition(QName refQName, String newLabel) { @@ -1323,18 +1323,18 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin private QName persistUpdatedAssocTitle(QName refQName, String newTitle) { ParameterCheck.mandatory("refQName", refQName); - + AssociationDefinition assocDefn = dictionaryService.getAssociation(refQName); if (assocDefn == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONNOT_FIND_ASSOC_DEF, refQName)); } - + NodeRef modelRef = getCustomModelRef(""); // defaults to RM_CUSTOM_URI M2Model deserializedModel = readCustomContentModel(modelRef); - + M2Aspect customAssocsAspect = deserializedModel.getAspect(RMC_CUSTOM_ASSOCS); - + for (M2ClassAssociation assoc : customAssocsAspect.getAssociations()) { if (refQName.toPrefixString(namespaceService).equals(assoc.getName())) @@ -1346,125 +1346,125 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } } writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("persistUpdatedAssocTitle: "+refQName+ "=" + newTitle + " to aspect: " + RMC_CUSTOM_ASSOCS); } - + return refQName; } - - public void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List allowedValues, MatchLogic matchLogic) + + public void addCustomConstraintDefinition(QName constraintName, String title, boolean caseSensitive, List allowedValues, MatchLogic matchLogic) { ParameterCheck.mandatory("constraintName", constraintName); ParameterCheck.mandatoryString("title", title); ParameterCheck.mandatory("allowedValues", allowedValues); - + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + String constraintNameAsPrefixString = constraintName.toPrefixString(namespaceService); - + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); if (customConstraint != null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONSTRAINT_EXISTS, constraintNameAsPrefixString)); } - + M2Constraint newCon = deserializedModel.createConstraint(constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE); - + newCon.setTitle(title); newCon.createParameter(PARAM_ALLOWED_VALUES, allowedValues); newCon.createParameter(PARAM_CASE_SENSITIVE, caseSensitive ? "true" : "false"); newCon.createParameter(PARAM_MATCH_LOGIC, matchLogic.toString()); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("addCustomConstraintDefinition: "+constraintNameAsPrefixString+" (valueCnt: "+allowedValues.size()+")"); } } - + /* - public void addCustomConstraintDefinition(QName constraintName, String description, Map parameters) + public void addCustomConstraintDefinition(QName constraintName, String description, Map parameters) { // TODO Auto-generated method stub } */ - + public void changeCustomConstraintValues(QName constraintName, List newAllowedValues) { ParameterCheck.mandatory("constraintName", constraintName); ParameterCheck.mandatory("newAllowedValues", newAllowedValues); - + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + String constraintNameAsPrefixString = constraintName.toPrefixString(namespaceService); - + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); if (customConstraint == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); } - + String type = customConstraint.getType(); if ((type == null) || (! type.equals(CUSTOM_CONSTRAINT_TYPE))) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); } - + customConstraint.removeParameter(PARAM_ALLOWED_VALUES); customConstraint.createParameter(PARAM_ALLOWED_VALUES, newAllowedValues); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("changeCustomConstraintValues: "+constraintNameAsPrefixString+" (valueCnt: "+newAllowedValues.size()+")"); } } - + public void changeCustomConstraintTitle(QName constraintName, String title) { ParameterCheck.mandatory("constraintName", constraintName); ParameterCheck.mandatoryString("title", title); - + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + String constraintNameAsPrefixString = constraintName.toPrefixString(namespaceService); - + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); if (customConstraint == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); } - + String type = customConstraint.getType(); if ((type == null) || (! type.equals(CUSTOM_CONSTRAINT_TYPE))) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); } - + customConstraint.setTitle(title); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("changeCustomConstraintTitle: "+constraintNameAsPrefixString+" (title: "+title+")"); } } - - public List getCustomConstraintDefinitions(QName modelQName) + + public List getCustomConstraintDefinitions(QName modelQName) { Collection conDefs = dictionaryService.getConstraints(modelQName, true); - + for (ConstraintDefinition conDef : conDefs) { Constraint con = conDef.getConstraint(); @@ -1473,36 +1473,36 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin conDefs.remove(conDef); } } - + return new ArrayList(conDefs); } - - public void removeCustomConstraintDefinition(QName constraintName) + + public void removeCustomConstraintDefinition(QName constraintName) { ParameterCheck.mandatory("constraintName", constraintName); - + NodeRef modelRef = getCustomModelRef(constraintName.getNamespaceURI()); M2Model deserializedModel = readCustomContentModel(modelRef); - + String constraintNameAsPrefixString = constraintName.toPrefixString(namespaceService); - + M2Constraint customConstraint = deserializedModel.getConstraint(constraintNameAsPrefixString); if (customConstraint == null) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CANNOT_FIND_CONSTRAINT, constraintNameAsPrefixString)); } - + deserializedModel.removeConstraint(constraintNameAsPrefixString); - + writeCustomContentModel(modelRef, deserializedModel); - + if (logger.isInfoEnabled()) { logger.info("deleteCustomConstraintDefinition: "+constraintNameAsPrefixString); } } - + private NodeRef getCustomModelRef(String uri) { if ((uri.equals("")) || (uri.equals(RecordsManagementModel.RM_CUSTOM_URI))) @@ -1514,13 +1514,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { // ALF-5875 List modelRefs = dictonaryRepositoryBootstrap.getModelRefs(); - + for (NodeRef modelRef : modelRefs) { try { M2Model model = readCustomContentModel(modelRef); - + for (M2Namespace namespace : model.getNamespaces()) { if (namespace.getUri().equals(uri)) @@ -1528,24 +1528,24 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin return modelRef; } } - } + } catch (DictionaryException de) { logger.warn("readCustomContentModel: skip model ("+modelRef+") whilst searching for uri ("+uri+"): "+de); } } - + throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_MODEL_NOT_FOUND, uri)); } } - + private M2Model readCustomContentModel(NodeRef modelNodeRef) { ContentReader reader = this.contentService.getReader(modelNodeRef, ContentModel.TYPE_CONTENT); - + if (reader.exists() == false) {throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CUSTOM_MODEL_NO_CONTENT, modelNodeRef.toString()));} - + InputStream contentIn = null; M2Model deserializedModel = null; try @@ -1566,16 +1566,16 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } return deserializedModel; } - + private void writeCustomContentModel(NodeRef modelRef, M2Model deserializedModel) { ContentWriter writer = this.contentService.getWriter(modelRef, ContentModel.TYPE_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_XML); writer.setEncoding("UTF-8"); - + ByteArrayOutputStream baos = new ByteArrayOutputStream(); deserializedModel.toXML(baos); - + String updatedModelXml; try { @@ -1589,7 +1589,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } } - + public QName getQNameForClientId(String localName) { //TODO 1. After certification. This implementation currently does not support reference, @@ -1597,7 +1597,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin //TODO 2. Note the implicit assumption here that all custom references will have // unique titles. This is, in fact, not guaranteed. - + QName propertyResult = null; for (QName qn : getCustomPropertyDefinitions().keySet()) { @@ -1606,12 +1606,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin propertyResult = qn; } } - + if (propertyResult != null) { return propertyResult; } - + QName referenceResult = null; for (QName refQn : getCustomReferenceDefinitions().keySet()) { @@ -1620,7 +1620,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin referenceResult = refQn; } } - + // TODO Handle the case where both are not null return referenceResult; } @@ -1632,13 +1632,13 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin // TODO log it's already taken. What to do? throw new IllegalArgumentException(I18NUtil.getMessage(MSG_ERROR_CLIENT_ID, clientId)); } - + String newGUID = GUID.generate(); QName newQName = QName.createQName(RM_CUSTOM_PREFIX, newGUID, namespaceService); - + return newQName; } - + public String[] splitSourceTargetId(String sourceTargetId) { if (!sourceTargetId.contains(SOURCE_TARGET_ID_SEPARATOR)) @@ -1647,12 +1647,12 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin } return sourceTargetId.split(SOURCE_TARGET_ID_SEPARATOR); } - + public String getCompoundIdFor(String sourceId, String targetId) { ParameterCheck.mandatoryString("sourceId", sourceId); ParameterCheck.mandatoryString("targetId", targetId); - + if (sourceId.contains(SOURCE_TARGET_ID_SEPARATOR)) { throw new IllegalArgumentException("sourceId cannot contain '" + SOURCE_TARGET_ID_SEPARATOR diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java index aa49a588ff..770d25527b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/SplitEmailAction.java @@ -56,9 +56,9 @@ import org.springframework.util.FileCopyUtils; /** * Split Email Action - * + * * Splits the attachments for an email message out to independent records. - * + * * @author Mark Rogers */ public class SplitEmailAction extends RMActionExecuterAbstractBase @@ -67,30 +67,30 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase private static final String MSG_NO_READ_MIME_MESSAGE = "rm.action.no-read-mime-message"; private static final String MSG_EMAIL_DECLARED = "rm.action.email-declared"; private static final String MSG_EMAIL_NOT_RECORD = "rm.action.email-not-record"; - + /** Relationship Labels */ private static final String REL_FROM = "Message"; private static final String REL_TO = "Attachment"; - + /** Logger */ private static Log logger = LogFactory.getLog(SplitEmailAction.class); private QName relationshipQName; - + public void bootstrap() { - String compoundId = recordsManagementAdminService.getCompoundIdFor(REL_FROM, REL_TO); - + String compoundId = recordsManagementAdminService.getCompoundIdFor(REL_FROM, REL_TO); + Map map = recordsManagementAdminService.getCustomReferenceDefinitions(); for (Map.Entry entry : map.entrySet()) { - if (compoundId.equals(entry.getValue().getTitle()) == true) + if (compoundId.equals(entry.getValue().getTitle(dictionaryService)) == true) { relationshipQName = entry.getKey(); break; } } - + if (relationshipQName == null) { relationshipQName = recordsManagementAdminService.addCustomChildAssocDefinition(REL_FROM, REL_TO); @@ -106,7 +106,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase { // get node type nodeService.getType(actionedUponNodeRef); - + if (logger.isDebugEnabled() == true) { logger.debug("split email:" + actionedUponNodeRef); @@ -117,8 +117,8 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase if (recordService.isDeclared(actionedUponNodeRef) == false) { ChildAssociationRef parent = nodeService.getPrimaryParent(actionedUponNodeRef); - - /** + + /** * Check whether the email message has already been split - do nothing if it has already been split */ List refs = nodeService.getTargetAssocs(actionedUponNodeRef, ImapModel.ASSOC_IMAP_ATTACHMENT); @@ -130,7 +130,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase } return; } - + /** * Get the content and if its a mime message then create atachments for each part */ @@ -152,12 +152,12 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase createAttachment(actionedUponNodeRef, parent.getParentRef(), part); } } - } - } + } + } catch (Exception e) { throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_READ_MIME_MESSAGE, e.toString()), e); - } + } } else { @@ -169,7 +169,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, actionedUponNodeRef.toString())); } } - + /** * Create attachment from Mime Message Part * @param messageNodeRef - the node ref of the mime message @@ -192,7 +192,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase logger.warn("Cannot decode file name '" + fileName + "'", e); } } - + Map messageProperties = nodeService.getProperties(messageNodeRef); String messageTitle = (String)messageProperties.get(ContentModel.PROP_NAME); if(messageTitle == null) @@ -201,24 +201,24 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase } else { - messageTitle = messageTitle + " - " + fileName; + messageTitle = messageTitle + " - " + fileName; } ContentType contentType = new ContentType(part.getContentType()); - + Map docProps = new HashMap(1); docProps.put(ContentModel.PROP_NAME, messageTitle + " - " + fileName); docProps.put(ContentModel.PROP_TITLE, fileName); - + /** * Create an attachment node in the same folder as the message */ - ChildAssociationRef attachmentRef = nodeService.createNode(parentNodeRef, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName), + ChildAssociationRef attachmentRef = nodeService.createNode(parentNodeRef, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName), ContentModel.TYPE_CONTENT, docProps); - + /** * Write the content into the new attachment node */ @@ -226,18 +226,18 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase writer.setMimetype(contentType.getBaseType()); OutputStream os = writer.getContentOutputStream(); FileCopyUtils.copy(part.getInputStream(), os); - + /** * Create a link from the message to the attachment - */ + */ createRMReference(messageNodeRef, attachmentRef.getChildRef()); - - + + } - + /** * Create a link from the message to the attachment - */ + */ private void createRMReference(final NodeRef parentRef, final NodeRef childRef) { AuthenticationUtil.runAsSystem(new RunAsWork() @@ -246,16 +246,16 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase public Void doWork() throws Exception { // add the relationship - recordsManagementAdminService.addCustomReference(parentRef, childRef, relationshipQName); - + recordsManagementAdminService.addCustomReference(parentRef, childRef, relationshipQName); + // add the IMAP attachment aspect nodeService.createAssociation( parentRef, childRef, ImapModel.ASSOC_IMAP_ATTACHMENT); - + return null; - } + } }); - } + } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java index 0cc4e8cdac..a305c362e9 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/audit/RecordsManagementAuditServiceImpl.java @@ -1291,7 +1291,7 @@ public class RecordsManagementAuditServiceImpl PropertyDefinition propDef = this.dictionaryService.getProperty(property); if (propDef != null) { - label = propDef.getTitle(); + label = propDef.getTitle(dictionaryService); } if (label == null) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/RFC822MetadataExtracter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/RFC822MetadataExtracter.java index 65f28e6919..a8f846f3dc 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/RFC822MetadataExtracter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/email/RFC822MetadataExtracter.java @@ -33,17 +33,17 @@ import org.alfresco.service.namespace.QName; /** * Extended RFC822 Metadata Extractor that is sensitive to whether we are in a RM * site or not. - * + * * @author Roy Wetherall */ public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata.RFC822MetadataExtracter { /** Reference to default properties */ - private static final String PROPERTIES_URL = "org/alfresco/repo/content/metadata/RFC822MetadataExtracter.properties"; - + private static final String PROPERTIES_URL = "alfresco/metadata/RFC822MetadataExtracter.properties"; + /** Node service */ private NodeService nodeService; - + /** * Sets the node service * @param nodeService node service @@ -52,7 +52,7 @@ public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata. { this.nodeService = nodeService; } - + /** * @see org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter#filterSystemProperties(java.util.Map, java.util.Map) */ @@ -73,7 +73,7 @@ public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata. } } } - + /** * @see org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter#getDefaultMapping() */ @@ -82,7 +82,7 @@ public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata. // Attempt to load the properties return readMappingProperties(PROPERTIES_URL); } - + /** * Given a set of properties, try and retrieve the node reference * @param properties node properties @@ -91,21 +91,21 @@ public class RFC822MetadataExtracter extends org.alfresco.repo.content.metadata. private NodeRef getNodeRef(Map properties) { NodeRef result = null; - + // Get the elements of the node reference String storeProto = (String)properties.get(ContentModel.PROP_STORE_PROTOCOL); String storeId = (String)properties.get(ContentModel.PROP_STORE_IDENTIFIER); String nodeId = (String)properties.get(ContentModel.PROP_NODE_UUID); - + if (storeProto != null && storeProto.length() != 0 && storeId != null && storeId.length() != 0 && nodeId != null && nodeId.length() != 0) - + { // Create the node reference result = new NodeRef(new StoreRef(storeProto, storeId), nodeId); } - + return result; } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java index 5768888b3c..62d73c695f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementFormFilter.java @@ -32,6 +32,7 @@ import org.alfresco.repo.forms.Form; import org.alfresco.repo.forms.FormData; import org.alfresco.repo.forms.processor.AbstractFilter; import org.alfresco.repo.forms.processor.node.FieldUtils; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; @@ -43,7 +44,7 @@ import org.apache.commons.logging.LogFactory; /** * Abstract base class for records management related form filter * implementations. - * + * * @author Gavin Cornwell */ public abstract class RecordsManagementFormFilter extends AbstractFilter @@ -60,10 +61,11 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt protected RecordsManagementService rmService; protected RecordsManagementAdminService rmAdminService; protected RecordService recordService; + protected DictionaryService dictionaryService; /** * Sets the NamespaceService instance - * + * * @param namespaceService The NamespaceService instance */ public void setNamespaceService(NamespaceService namespaceService) @@ -73,7 +75,7 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt /** * Sets the node service - * + * * @param nodeService The NodeService instance */ public void setNodeService(NodeService nodeService) @@ -83,17 +85,17 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt /** * Sets the RecordsManagementServiceRegistry instance - * + * * @param rmServiceRegistry The RecordsManagementServiceRegistry instance */ public void setRecordsManagementServiceRegistry(RecordsManagementServiceRegistry rmServiceRegistry) { this.rmServiceRegistry = rmServiceRegistry; } - + /** * Sets the RecordsManagementService instance - * + * * @param rmService The RecordsManagementService instance */ public void setRecordsManagementService(RecordsManagementService rmService) @@ -103,14 +105,14 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt /** * Sets the RecordsManagementAdminService instance - * + * * @param rmAdminService The RecordsManagementAdminService instance */ public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) { this.rmAdminService = rmAdminService; } - + /** * @param recordService record service */ @@ -118,10 +120,18 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt { this.recordService = recordService; } - + + /** + * @param dictionaryService dictionary service + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + /** * Add property fields to group - * + * * @param form * @param props * @param setId @@ -133,17 +143,17 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt for (Map.Entry entry : props.entrySet()) { PropertyDefinition prop = entry.getValue(); - + String id = form.getItem().getId(); id = id.replaceFirst("/", "://"); NodeRef nodeRef = new NodeRef(id); Serializable value = nodeService.getProperty(nodeRef, entry.getKey()); - + FieldGroup group = new FieldGroup(setId, null, false, false, null); - Field field = FieldUtils.makePropertyField(prop, value, group, namespaceService); - + Field field = FieldUtils.makePropertyField(prop, value, group, namespaceService, dictionaryService); + form.addField(field); - + if (logger.isDebugEnabled() == true) { logger.debug("Adding custom property .. " + prop.getName().toString() + " .. with value " + value + ".. to group .. " + setId); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java index 7379f3138d..4caccbd84a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementNodeFormFilter.java @@ -54,7 +54,7 @@ import org.apache.commons.logging.LogFactory; * management type are provided as part of the Form and also assigned to the * same field group. *

- * + * * @author Gavin Cornwell */ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter implements RecordsManagementModel, DOD5015Model @@ -68,23 +68,23 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter /** Dictionary service */ protected DictionaryService dictionaryService; - + /** Disposition service */ - protected DispositionService dispositionService; + protected DispositionService dispositionService; /** * Sets the data dictionary service - * + * * @param dictionaryService The DictionaryService instance */ public void setDictionaryService(DictionaryService dictionaryService) { this.dictionaryService = dictionaryService; } - + /** * Sets the disposition service - * + * * @param dispositionService disposition service */ public void setDispositionService(DispositionService dispositionService) @@ -97,32 +97,32 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter */ @Override public void afterGenerate( - NodeRef nodeRef, - List fields, - List forcedFields, + NodeRef nodeRef, + List fields, + List forcedFields, Form form, Map context) { if (rmService.isFilePlanComponent(nodeRef) == true) - { + { // add all the custom properties addCustomPropertyFieldsToGroup(form, nodeRef); - + FilePlanComponentKind kind = rmService.getFilePlanComponentKind(nodeRef); if (FilePlanComponentKind.RECORD.equals(kind) == true) { // add all the record meta-data aspect properties addRecordMetadataPropertyFieldsToGroup(form, nodeRef); - + // add required transient properties addTransientProperties(form, nodeRef); - + // add the supplemental marking list property forceSupplementalMarkingListProperty(form, nodeRef); - + // protect uneditable properties protectRecordProperties(form, nodeRef); - + // if the record is the result of an email we need to 'protect' some fields if (this.nodeService.hasAspect(nodeRef, ImapModel.ASPECT_IMAP_CONTENT)) { @@ -133,14 +133,14 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter { // add the supplemental marking list property forceSupplementalMarkingListProperty(form, nodeRef); - + // add required transient properties addTransientProperties(form, nodeRef); } else if (FilePlanComponentKind.DISPOSITION_SCHEDULE.equals(kind) == true) { // use the same mechanism used to determine whether steps can be removed from the - // schedule to determine whether the disposition level can be changed i.e. record + // schedule to determine whether the disposition level can be changed i.e. record // level or folder level. DispositionSchedule schedule = new DispositionScheduleImpl(this.rmServiceRegistry, this.nodeService, nodeRef); if (dispositionService.hasDisposableItems(schedule) == true) @@ -148,19 +148,19 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter protectRecordLevelDispositionPropertyField(form); } } - + } } - + /** - * + * * @param form * @param nodeRef */ protected void addCustomPropertyFieldsToGroup(Form form, NodeRef nodeRef) { Set customisables = rmAdminService.getCustomisable(nodeRef); - + // Compatibility support: don't show category properties if node of type series QName type = nodeService.getType(nodeRef); if (CompatibilityModel.TYPE_RECORD_SERIES.equals(type) == true) @@ -168,22 +168,22 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter // remove record category from the list of customisable types to apply to the form customisables.remove(TYPE_RECORD_CATEGORY); } - + for (QName customisable : customisables) { addPropertyFieldsToGroup(form, rmAdminService.getCustomPropertyDefinitions(customisable), CUSTOM_RM_FIELD_GROUP_ID); } } - + /** - * + * * @param form * @param nodeRef */ protected void addRecordMetadataPropertyFieldsToGroup(Form form, NodeRef nodeRef) { Set aspects = recordService.getRecordMetaDataAspects(); - + for (QName aspect : aspects) { if (nodeService.hasAspect(nodeRef, aspect) == true) @@ -199,26 +199,26 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter * Forces the "rmc:supplementalMarkingList" property to be present, if it is * already on the given node this method does nothing, otherwise a property * field definition is generated for the property. - * + * * @param form The Form instance to add the property to * @param nodeRef The node the form is being generated for */ protected void forceSupplementalMarkingListProperty(Form form, NodeRef nodeRef) { - if (!this.nodeService.hasAspect(nodeRef, + if (!this.nodeService.hasAspect(nodeRef, RecordsManagementCustomModel.ASPECT_SUPPLEMENTAL_MARKING_LIST)) { PropertyDefinition propDef = this.dictionaryService.getProperty( RecordsManagementCustomModel.PROP_SUPPLEMENTAL_MARKING_LIST); - + if (propDef != null) { - Field field = FieldUtils.makePropertyField(propDef, null, null, namespaceService); + Field field = FieldUtils.makePropertyField(propDef, null, null, namespaceService, dictionaryService); form.addField(field); } else if (logger.isWarnEnabled()) { - logger.warn("Could not add " + + logger.warn("Could not add " + RecordsManagementCustomModel.PROP_SUPPLEMENTAL_MARKING_LIST.getLocalName() + " property as it's definition could not be found"); } @@ -226,7 +226,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter } /** - * + * * @param form * @param nodeRef */ @@ -236,7 +236,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter { addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, recordService.isDeclared(nodeRef)); } - + DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef); if (ds != null) { @@ -245,7 +245,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter { addTransientPropertyField(form, TRANSIENT_DISPOSITION_INSTRUCTIONS, DataTypeDefinition.TEXT, instructions); } - + NodeRef recordCategory = dispositionService.getAssociatedRecordsManagementContainer(ds); if (recordCategory != null) { @@ -255,11 +255,11 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter addTransientPropertyField(form, TRANSIENT_CATEGORY_ID, DataTypeDefinition.TEXT, categoryId); } } - } + } } - + /** - * + * * @param form * @param name * @param type @@ -276,9 +276,9 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter form.addFieldDefinition(declaredField); form.addData(dataKeyName, value); } - + /** - * + * * @param form * @param nodeRef */ @@ -296,15 +296,15 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter prefixName = "cm:content"; } else - { + { prefixName = fieldDef.getName(); } - + if (logger.isDebugEnabled() == true) { logger.debug("Checking property " + prefixName + " is editable by user " + AuthenticationUtil.getFullyAuthenticatedUser()); } - + QName qname = QName.createQName(prefixName, namespaceService); if (recordService.isPropertyEditable(nodeRef, qname) == false) { @@ -315,13 +315,13 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter fieldDef.setProtectedField(true); } } - } + } } - + /** * Marks all the fields that contain data extracted from an email * as protected fields. - * + * * @param form The Form instance to add the property to * @param nodeRef The node the form is being generated for */ @@ -332,14 +332,14 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter for (FieldDefinition fieldDef : fieldDefs) { String prefixName = fieldDef.getName(); - - // check the value of the property, if empty then do not mark property + + // check the value of the property, if empty then do not mark property // as read only QName qname = QName.createQName(prefixName, namespaceService); Serializable value = nodeService.getProperty(nodeRef, qname); if (value != null) - { - if (prefixName.equals("cm:title") || + { + if (prefixName.equals("cm:title") || prefixName.equals("cm:author") || prefixName.equals("rma:originator") || prefixName.equals("rma:publicationDate") || @@ -351,16 +351,16 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter } } } - + if (logger.isDebugEnabled() == true) { logger.debug("Set email related fields to be protected"); } } - + /** * Marks the recordLevelDisposition property as protected to disable editing - * + * * @param form The Form instance */ protected void protectRecordLevelDispositionPropertyField(Form form) @@ -375,7 +375,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter break; } } - + if (logger.isDebugEnabled()) logger.debug("Set 'rma:recordLevelDisposition' field to be protected as record folders or records are present"); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilter.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilter.java index e2a56cbb83..b61b26355e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilter.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/forms/RecordsManagementTypeFormFilter.java @@ -49,7 +49,7 @@ import org.springframework.extensions.surf.util.ParameterCheck; * The filter also ensures that any custom properties defined for the records * management type are provided as part of the Form. *

- * + * * @author Gavin Cornwell */ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter implements RecordsManagementModel @@ -66,10 +66,10 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter protected static final FieldGroup TITLE_FIELD_GROUP = new FieldGroup(TITLE_FIELD_GROUP_ID, null, false, false, null); protected static final FieldGroup DESC_FIELD_GROUP = new FieldGroup(DESC_FIELD_GROUP_ID, null, false, false, null); protected static final FieldGroup OTHER_FIELD_GROUP = new FieldGroup(OTHER_FIELD_GROUP_ID, null, false, false, null); - + /** Identifier service */ protected IdentifierService identifierService; - + /** * @param identifierService identifier service */ @@ -77,7 +77,7 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter { this.identifierService = identifierService; } - + /* * @see * org.alfresco.repo.forms.processor.Filter#afterGenerate(java.lang.Object, @@ -87,12 +87,12 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter public void afterGenerate(TypeDefinition type, List fields, List forcedFields, Form form, Map context) { - QName typeName = type.getName(); + QName typeName = type.getName(); if (rmAdminService.isCustomisable(typeName) == true) { - addCustomRMProperties(typeName, form); + addCustomRMProperties(typeName, form); } - + // What about any mandatory aspects? Set aspects = type.getDefaultAspectNames(); for (QName aspect : aspects) @@ -107,7 +107,7 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter /** * Adds a property definition for each of the custom properties for the * given RM type to the given form. - * + * * @param rmTypeCustomAspect Enum representing the RM type to add custom * properties for * @param form The form to add the properties to @@ -116,20 +116,20 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter { ParameterCheck.mandatory("customisableType", customisableType); ParameterCheck.mandatory("form", form); - + Map customProps = rmAdminService.getCustomPropertyDefinitions(customisableType); - + if (customProps != null) { if (logger.isDebugEnabled() == true) { logger.debug("Found " + customProps.size() + " custom properties for customisable type " + customisableType); } - + // setup field definition for each custom property Collection properties = customProps.values(); FieldGroup group = new FieldGroup(CUSTOM_RM_FIELD_GROUP_ID, null, false, false, null); - List fields = FieldUtils.makePropertyFields(properties, group, namespaceService); + List fields = FieldUtils.makePropertyFields(properties, group, namespaceService, dictionaryService); form.addFields(fields); } } @@ -140,5 +140,5 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter public void afterPersist(TypeDefinition item, FormData data, final NodeRef nodeRef) { } - + } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index 43f46f27d5..91083cb218 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -36,7 +36,7 @@ import org.json.simple.JSONObject; /** * Extend JSON conversion component to include RM specifics. - * + * * @author Roy Wetherall */ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONConversionComponent @@ -162,7 +162,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC if (unfiledRecordContainer != null) { rmNodeValues.put("unfiledRecordContainer", unfiledRecordContainer.toString()); - rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, useShortQName)); + rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName)); QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType(); rmNodeValues.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString()); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java index ed0437504d..392d0844be 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/notification/RecordsManagementNotificationHelper.java @@ -245,7 +245,7 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod notificationContext.setAsyncNotification(false); notificationContext.setIgnoreNotificationFailure(true); - notificationContext.setBodyTemplate(getDueForReviewTemplate()); + notificationContext.setBodyTemplate(getDueForReviewTemplate().toString()); Map args = new HashMap(1, 1.0f); args.put("records", (Serializable)records); args.put("site", getSiteName(root)); @@ -286,7 +286,7 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod notificationContext.setAsyncNotification(false); notificationContext.setIgnoreNotificationFailure(true); - notificationContext.setBodyTemplate(supersededTemplate); + notificationContext.setBodyTemplate(supersededTemplate.toString()); Map args = new HashMap(1, 1.0f); args.put("record", record); args.put("site", getSiteName(root)); @@ -331,13 +331,13 @@ public class RecordsManagementNotificationHelper implements RecordsManagementMod args.put("rejectDate", rejectDate); args.put("recordId", recordId); args.put("recordName", recordName); - + NotificationContext notificationContext = new NotificationContext(); notificationContext.setAsyncNotification(true); notificationContext.setIgnoreNotificationFailure(true); notificationContext.addTo(recordCreator); notificationContext.setSubject(I18NUtil.getMessage(MSG_SUBJECT_RECORD_REJECTED)); - notificationContext.setBodyTemplate(getRejectedTemplate()); + notificationContext.setBodyTemplate(getRejectedTemplate().toString()); notificationContext.setTemplateArgs(args); notificationService.sendNotification(EMailNotificationProvider.NAME, notificationContext); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionsGet.java index 026962c944..f81040b477 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomReferenceDefinitionsGet.java @@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition; +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; @@ -40,7 +41,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * This class provides the implementation for the customrefdefinitions.get webscript. - * + * * @author Neil McErlean */ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript @@ -52,23 +53,29 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript private static final String TARGET = "target"; private static final String CUSTOM_REFS = "customRefs"; private static Log logger = LogFactory.getLog(CustomReferenceDefinitionsGet.class); - + private RecordsManagementAdminService rmAdminService; + private DictionaryService dictionaryService; public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) { this.rmAdminService = rmAdminService; } + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(); - + Map templateVars = req.getServiceMatch().getTemplateVars(); String refId = templateVars.get(REF_ID); - - + + if (logger.isDebugEnabled()) { logger.debug("Getting custom reference definitions with refId: " + String.valueOf(refId)); @@ -81,7 +88,7 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript if (refId != null) { QName qn = rmAdminService.getQNameForClientId(refId); - + AssociationDefinition assDef = currentCustomRefs.get(qn); if (assDef == null) { @@ -100,20 +107,20 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript } List> listOfReferenceData = new ArrayList>(); - + for (Entry entry : currentCustomRefs.entrySet()) { Map data = new HashMap(); AssociationDefinition nextValue = entry.getValue(); - + CustomReferenceType referenceType = nextValue instanceof ChildAssociationDefinition ? CustomReferenceType.PARENT_CHILD : CustomReferenceType.BIDIRECTIONAL; - + data.put(REFERENCE_TYPE, referenceType.toString()); // It is the title which stores either the label, or the source and target. - String nextTitle = nextValue.getTitle(); + String nextTitle = nextValue.getTitle(dictionaryService); if (CustomReferenceType.PARENT_CHILD.equals(referenceType)) { if (nextTitle != null) @@ -136,10 +143,10 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript { throw new WebScriptException("Unsupported custom reference type: " + referenceType); } - + listOfReferenceData.add(data); } - + if (logger.isDebugEnabled()) { logger.debug("Retrieved custom reference definitions: " + listOfReferenceData.size()); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefsGet.java index 4a2dfbe997..a65e8633f8 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomRefsGet.java @@ -26,6 +26,7 @@ import java.util.Map; import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService; import org.alfresco.service.cmr.dictionary.AssociationDefinition; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; @@ -38,7 +39,7 @@ import org.apache.commons.logging.LogFactory; /** * This class provides the implementation for the customrefs.get webscript. - * + * * @author Neil McErlean */ public class CustomRefsGet extends AbstractRmWebScript @@ -56,22 +57,28 @@ public class CustomRefsGet extends AbstractRmWebScript private static final String CUSTOM_REFS_TO = "customRefsTo"; private static final String NODE_NAME = "nodeName"; private static final String NODE_TITLE = "nodeTitle"; - + private static Log logger = LogFactory.getLog(CustomRefsGet.class); private RecordsManagementAdminService rmAdminService; - + private DictionaryService dictionaryService; + public void setRecordsManagementAdminService(RecordsManagementAdminService rmAdminService) { this.rmAdminService = rmAdminService; } + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map ftlModel = new HashMap(); - + NodeRef node = parseRequestForNodeRef(req); - + if (logger.isDebugEnabled()) { logger.debug("Getting custom reference instances for " + node); @@ -79,27 +86,27 @@ public class CustomRefsGet extends AbstractRmWebScript // All the references that come 'out' from this node. List> listOfOutwardReferenceData = new ArrayList>(); - + List assocsFromThisNode = this.rmAdminService.getCustomReferencesFrom(node); addBidirectionalReferenceData(listOfOutwardReferenceData, assocsFromThisNode); - + List childAssocs = this.rmAdminService.getCustomChildReferences(node); addParentChildReferenceData(listOfOutwardReferenceData, childAssocs); - + // All the references that come 'in' to this node. List> listOfInwardReferenceData = new ArrayList>(); - + List toAssocs = this.rmAdminService.getCustomReferencesTo(node); addBidirectionalReferenceData(listOfInwardReferenceData, toAssocs); - + List parentAssocs = this.rmAdminService.getCustomParentReferences(node); addParentChildReferenceData(listOfInwardReferenceData, parentAssocs); - + if (logger.isDebugEnabled()) { logger.debug("Retrieved custom reference instances: " + assocsFromThisNode); } - + ftlModel.put(NODE_NAME, nodeService.getProperty(node, ContentModel.PROP_NAME)); ftlModel.put(NODE_TITLE, nodeService.getProperty(node, ContentModel.PROP_TITLE)); ftlModel.put(CUSTOM_REFS_FROM, listOfOutwardReferenceData); @@ -112,7 +119,7 @@ public class CustomRefsGet extends AbstractRmWebScript * This method goes through the associationRefs specified and constructs a Map * for each assRef. FTL-relevant data are added to that map. The associationRefs must all be * parent/child references. - * + * * @param listOfReferenceData * @param assocs */ @@ -124,23 +131,23 @@ public class CustomRefsGet extends AbstractRmWebScript Map data = new HashMap(); QName typeQName = childAssRef.getTypeQName(); - + data.put(CHILD_REF, childAssRef.getChildRef().toString()); data.put(PARENT_REF, childAssRef.getParentRef().toString()); AssociationDefinition assDef = rmAdminService.getCustomReferenceDefinitions().get(typeQName); - + if (assDef != null) { - String compoundTitle = assDef.getTitle(); - + String compoundTitle = assDef.getTitle(dictionaryService); + data.put(REF_ID, typeQName.getLocalName()); - + String[] sourceAndTarget = rmAdminService.splitSourceTargetId(compoundTitle); data.put(SOURCE, sourceAndTarget[0]); data.put(TARGET, sourceAndTarget[1]); data.put(REFERENCE_TYPE, CustomReferenceType.PARENT_CHILD.toString()); - + listOfReferenceData.add(data); } } @@ -150,7 +157,7 @@ public class CustomRefsGet extends AbstractRmWebScript * This method goes through the associationRefs specified and constructs a Map * for each assRef. FTL-relevant data are added to that map. The associationRefs must all be * bidirectional references. - * + * * @param listOfReferenceData * @param assocs */ @@ -163,15 +170,15 @@ public class CustomRefsGet extends AbstractRmWebScript QName typeQName = assRef.getTypeQName(); AssociationDefinition assDef = rmAdminService.getCustomReferenceDefinitions().get(typeQName); - + if (assDef != null) { - data.put(LABEL, assDef.getTitle()); + data.put(LABEL, assDef.getTitle(dictionaryService)); data.put(REF_ID, typeQName.getLocalName()); data.put(REFERENCE_TYPE, CustomReferenceType.BIDIRECTIONAL.toString()); data.put(SOURCE_REF, assRef.getSourceRef().toString()); data.put(TARGET_REF, assRef.getTargetRef().toString()); - + listOfReferenceData.add(data); } } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionPropertiesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionPropertiesGet.java index 376144dc3f..ba2b619b5b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionPropertiesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/DispositionPropertiesGet.java @@ -26,6 +26,7 @@ import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService; import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; @@ -42,33 +43,44 @@ public class DispositionPropertiesGet extends DeclarativeWebScript { protected DispositionService dispositionService; protected NamespaceService namespaceService; - + protected DictionaryService dictionaryService; + /** * Sets the disposition service - * + * * @param dispositionService the disposition service */ public void setDispositionService(DispositionService dispositionService) { this.dispositionService = dispositionService; } - + /** * Sets the NamespaceService instance - * + * * @param namespaceService The NamespaceService instance */ public void setNamespaceService(NamespaceService namespaceService) { this.namespaceService = namespaceService; } - + + /** + * Sets the DictionaryService instance + * + * @param dictionaryService The DictionaryService instance + */ + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + /* * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) */ @Override protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) - { + { boolean recordLevel = false; String recordLevelValue = req.getParameter("recordlevel"); if (recordLevelValue != null) @@ -76,18 +88,18 @@ public class DispositionPropertiesGet extends DeclarativeWebScript recordLevel = Boolean.valueOf(recordLevelValue); } String dispositionAction = req.getParameter("dispositionaction"); - + Collection dispositionProperties = dispositionService.getDispositionProperties(recordLevel, dispositionAction); List> items = new ArrayList>(dispositionProperties.size()); for (DispositionProperty dispositionProperty : dispositionProperties) { PropertyDefinition propDef = dispositionProperty.getPropertyDefinition(); QName propName = dispositionProperty.getQName(); - + if (propDef != null) { Map item = new HashMap(2); - String propTitle = propDef.getTitle(); + String propTitle = propDef.getTitle(dictionaryService); if (propTitle == null || propTitle.length() == 0) { propTitle = StringUtils.capitalize(propName.getLocalName()); @@ -97,7 +109,7 @@ public class DispositionPropertiesGet extends DeclarativeWebScript items.add(item); } } - + // create model object with the lists model Map model = new HashMap(1); model.put("properties", items); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java index 6e7aef11cb..6852b1a4cd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/ListOfValuesGet.java @@ -49,7 +49,7 @@ import org.springframework.util.StringUtils; /** * Implementation for Java backed webscript to return lists * of values for various records management services. - * + * * @author Gavin Cornwell */ public class ListOfValuesGet extends DeclarativeWebScript @@ -61,50 +61,50 @@ public class ListOfValuesGet extends DeclarativeWebScript protected DispositionService dispositionService; protected DictionaryService ddService; protected NamespaceService namespaceService; - + /** * Sets the RecordsManagementService instance - * + * * @param rmService The RecordsManagementService instance */ public void setRecordsManagementService(RecordsManagementService rmService) { this.rmService = rmService; } - + /** * Sets the RecordsManagementActionService instance - * + * * @param rmActionService The RecordsManagementActionService instance */ public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) { this.rmActionService = rmActionService; } - + /** * Sets the RecordsManagementAuditService instance - * + * * @param rmAuditService The RecordsManagementAuditService instance */ public void setRecordsManagementAuditService(RecordsManagementAuditService rmAuditService) { this.rmAuditService = rmAuditService; } - + /** * Sets the RecordsManagementEventService instance - * + * * @param rmEventService The RecordsManagementEventService instance */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) { this.rmEventService = rmEventService; } - + /** * Sets the disposition service - * + * * @param dispositionService the disposition service */ public void setDispositionService(DispositionService dispositionService) @@ -114,24 +114,24 @@ public class ListOfValuesGet extends DeclarativeWebScript /** * Sets the DictionaryService instance - * + * * @param ddService The DictionaryService instance */ public void setDictionaryService(DictionaryService ddService) { this.ddService = ddService; } - + /** * Sets the NamespaceService instance - * + * * @param namespaceService The NamespaceService instance */ public void setNamespaceService(NamespaceService namespaceService) { this.namespaceService = namespaceService; } - + /* * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) */ @@ -146,16 +146,16 @@ public class ListOfValuesGet extends DeclarativeWebScript listsModel.put("periodTypes", createPeriodTypesModel(requestUrl)); listsModel.put("periodProperties", createPeriodPropertiesModel(requestUrl)); listsModel.put("auditEvents", createAuditEventsModel(requestUrl)); - + // create model object with the lists model Map model = new HashMap(1); model.put("lists", listsModel); return model; } - + /** * Creates the model for the list of disposition actions. - * + * * @param baseUrl The base URL of the service * @return model of disposition actions list */ @@ -171,18 +171,18 @@ public class ListOfValuesGet extends DeclarativeWebScript item.put("value", dispositionAction.getName()); items.add(item); } - + // create the model Map model = new HashMap(2); model.put("url", baseUrl + "/dispositionactions"); model.put("items", items); - + return model; } - + /** * Creates the model for the list of events. - * + * * @param baseUrl The base URL of the service * @return model of events list */ @@ -196,22 +196,22 @@ public class ListOfValuesGet extends DeclarativeWebScript Map item = new HashMap(3); item.put("label", event.getDisplayLabel()); item.put("value", event.getName()); - item.put("automatic", + item.put("automatic", this.rmEventService.getEventType(event.getType()).isAutomaticEvent()); items.add(item); } - + // create the model Map model = new HashMap(2); model.put("url", baseUrl + "/events"); model.put("items", items); - + return model; } - + /** * Creates the model for the list of period types. - * + * * @param baseUrl The base URL of the service * @return model of period types list */ @@ -231,18 +231,18 @@ public class ListOfValuesGet extends DeclarativeWebScript items.add(item); } } - + // create the model Map model = new HashMap(2); model.put("url", baseUrl + "/periodtypes"); model.put("items", items); - + return model; } - + /** * Creates the model for the list of period properties. - * + * * @param baseUrl The base URL of the service * @return model of period properties list */ @@ -255,11 +255,11 @@ public class ListOfValuesGet extends DeclarativeWebScript { PropertyDefinition propDef = dispositionProperty.getPropertyDefinition(); QName propName = dispositionProperty.getQName(); - + if (propDef != null) { Map item = new HashMap(2); - String propTitle = propDef.getTitle(); + String propTitle = propDef.getTitle(ddService); if (propTitle == null || propTitle.length() == 0) { propTitle = StringUtils.capitalize(propName.getLocalName()); @@ -269,18 +269,18 @@ public class ListOfValuesGet extends DeclarativeWebScript items.add(item); } } - + // create the model Map model = new HashMap(2); model.put("url", baseUrl + "/periodproperties"); model.put("items", items); - + return model; } - + /** * Creates the model for the list of audit events. - * + * * @param baseUrl The base URL of the service * @return model of audit events list */ @@ -296,12 +296,12 @@ public class ListOfValuesGet extends DeclarativeWebScript item.put("value", event.getName()); items.add(item); } - + // create the model Map model = new HashMap(2); model.put("url", baseUrl + "/auditevents"); model.put("items", items); - + return model; } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java index d97cc1a53e..a08d8b6860 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchPropertiesGet.java @@ -38,17 +38,17 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * RM serach properties GET web script - * + * * @author Roy Wetherall */ public class RMSearchPropertiesGet extends DeclarativeWebScript { /** Services */ - private RecordsManagementAdminService adminService; - private RecordService recordService; - private DictionaryService dictionaryService; + private RecordsManagementAdminService adminService; + private RecordService recordService; + private DictionaryService dictionaryService; private NamespaceService namespaceService; - + /** * @param adminService records management admin service */ @@ -56,7 +56,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript { this.adminService = adminService; } - + /** * @param recordService record service */ @@ -64,7 +64,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript { this.recordService = recordService; } - + /** * @param dictionaryService dictionary service */ @@ -72,7 +72,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript { this.dictionaryService = dictionaryService; } - + /** * @param namespaceService namespace service */ @@ -80,7 +80,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript { this.namespaceService = namespaceService; } - + /** * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) */ @@ -88,9 +88,9 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) { Map model = new HashMap(13); - + List groups = new ArrayList(5); - + Set aspects = recordService.getRecordMetaDataAspects(); for (QName aspect : aspects) { @@ -103,9 +103,9 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript propObjs[index] = propObj; index ++; } - + AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); - Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(), propObjs); + Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(), propObjs); groups.add(group); } @@ -118,74 +118,74 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript propObjs[index] = propObj; index ++; } - - Group group = new Group("rmcustom", "Custom", propObjs); + + Group group = new Group("rmcustom", "Custom", propObjs); groups.add(group); - + model.put("groups", groups); return model; } - + public class Group - { + { private String id; private String label; private Property[] properties; - + public Group(String id, String label, Property[] properties) { this.id = id; this.label = label; this.properties = properties; } - + public String getId() { return id; } - + public String getLabel() { return label; } - + public Property[] getProperties() { return properties; - } + } } - + public class Property { private String prefix; private String shortName; private String label; private String type; - + public Property(PropertyDefinition propertyDefinition) { QName qName = propertyDefinition.getName().getPrefixedQName(namespaceService); this.prefix = QName.splitPrefixedQName(qName.toPrefixString())[0]; this.shortName = qName.getLocalName(); - this.label = propertyDefinition.getTitle(); + this.label = propertyDefinition.getTitle(dictionaryService); this.type = propertyDefinition.getDataType().getName().getLocalName(); } - + public String getPrefix() { return prefix; } - + public String getShortName() { return shortName; } - + public String getLabel() { return label; } - + public String getType() { return type; diff --git a/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java b/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java index bb5c68cfd8..15bdd092b9 100644 --- a/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java +++ b/rm-server/source/java/org/alfresco/repo/security/authority/RMAuthorityDAOImpl.java @@ -18,899 +18,34 @@ */ package org.alfresco.repo.security.authority; -import java.io.Serializable; -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.TreeSet; -import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.query.CannedQuery; -import org.alfresco.query.CannedQueryFactory; -import org.alfresco.query.CannedQueryResults; -import org.alfresco.query.PagingRequest; -import org.alfresco.query.PagingResults; -import org.alfresco.repo.cache.SimpleCache; -import org.alfresco.repo.domain.permissions.AclDAO; -import org.alfresco.repo.node.NodeServicePolicies; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; -import org.alfresco.repo.security.person.PersonServiceImpl; -import org.alfresco.repo.tenant.TenantService; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -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.repository.StoreRef; -import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; -import org.alfresco.service.cmr.search.SearchParameters; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AuthorityService.AuthorityFilter; import org.alfresco.service.cmr.security.AuthorityType; -import org.alfresco.service.cmr.security.NoSuchPersonException; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.security.PersonService.PersonInfo; -import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; -import org.alfresco.util.EqualsHelper; -import org.alfresco.util.ISO9075; -import org.alfresco.util.Pair; -import org.alfresco.util.ParameterCheck; -import org.alfresco.util.SearchLanguageConversion; -import org.alfresco.util.registry.NamedObjectRegistry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** - * FIXME !!!!
- * This class overrides the original {@link AuthorityDAOImpl} class
- * We need to modify two private methods in the original class
+ * This class extends {@link AuthorityDAOImpl}
+ * and overrides two methods from the original class
*
* addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type)
*
* and
*
* addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern)
- *
- * After changing the modifiers for those methods, this class can extend from the original one and those methods can
- * overriden in this class. For the time being the whole class has been copied and the needed changes have been
- * made directly in this class. - * */ -public class RMAuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy +public class RMAuthorityDAOImpl extends AuthorityDAOImpl { - private static Log logger = LogFactory.getLog(AuthorityDAOImpl.class); - - private static final String CANNED_QUERY_AUTHS_LIST = "authsGetAuthoritiesCannedQueryFactory"; // see authority-services-context.xml - - private StoreRef storeRef; - - private NodeService nodeService; - - private NamespacePrefixResolver namespacePrefixResolver; - - private QName qnameAssocSystem; - - private QName qnameAssocAuthorities; - - private QName qnameAssocZones; - - private SearchService searchService; - - private DictionaryService dictionaryService; - - private PersonService personService; - - private TenantService tenantService; - - private SimpleCache, NodeRef> authorityLookupCache; - - private static final NodeRef NULL_NODEREF = new NodeRef("null", "null", "null"); - - private SimpleCache> userAuthorityCache; - - private SimpleCache, List> zoneAuthorityCache; - - private SimpleCache> childAuthorityCache; - - /** System Container ref cache (Tennant aware) */ - private Map systemContainerRefs = new ConcurrentHashMap(4); - - private AclDAO aclDao; - - private PolicyComponent policyComponent; - - /** The number of authorities in a zone to pre-cache, allowing quick generation of 'first n' results. */ - private int zoneAuthoritySampleSize = 10000; - - private NamedObjectRegistry> cannedQueryRegistry; - - private static final Collection SEARCHABLE_AUTHORITY_TYPES = new LinkedList(); - static + protected void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type) { - SEARCHABLE_AUTHORITY_TYPES.add(AuthorityType.ROLE); - SEARCHABLE_AUTHORITY_TYPES.add(AuthorityType.GROUP); - } - - public RMAuthorityDAOImpl() - { - super(); - } - - - /** - * Sets number of authorities in a zone to pre-cache, allowing quick generation of 'first n' results and adaption of - * search technique based on hit rate. - * - * @param zoneAuthoritySampleSize - * the zoneAuthoritySampleSize to set - */ - public void setZoneAuthoritySampleSize(int zoneAuthoritySampleSize) - { - this.zoneAuthoritySampleSize = zoneAuthoritySampleSize; - } - - public void setStoreUrl(String storeUrl) - { - this.storeRef = new StoreRef(storeUrl); - } - - public void setDictionaryService(DictionaryService dictionaryService) - { - this.dictionaryService = dictionaryService; - } - - public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver) - { - this.namespacePrefixResolver = namespacePrefixResolver; - qnameAssocSystem = QName.createQName("sys", "system", namespacePrefixResolver); - qnameAssocAuthorities = QName.createQName("sys", "authorities", namespacePrefixResolver); - qnameAssocZones = QName.createQName("sys", "zones", namespacePrefixResolver); - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - public void setSearchService(SearchService searchService) - { - this.searchService = searchService; - } - - public void setAuthorityLookupCache(SimpleCache, NodeRef> authorityLookupCache) - { - this.authorityLookupCache = authorityLookupCache; - } - - public void setUserAuthorityCache(SimpleCache> userAuthorityCache) - { - this.userAuthorityCache = userAuthorityCache; - } - - public void setZoneAuthorityCache(SimpleCache, List> zoneAuthorityCache) - { - this.zoneAuthorityCache = zoneAuthorityCache; - } - - public void setChildAuthorityCache(SimpleCache> childAuthorityCache) - { - this.childAuthorityCache = childAuthorityCache; - } - - public void setPersonService(PersonService personService) - { - this.personService = personService; - } - - public void setTenantService(TenantService tenantService) - { - this.tenantService = tenantService; - } - - public void setAclDAO(AclDAO aclDao) - { - this.aclDao = aclDao; - } - - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - public void setCannedQueryRegistry(NamedObjectRegistry> cannedQueryRegistry) - { - this.cannedQueryRegistry = cannedQueryRegistry; - } - - - public boolean authorityExists(String name) - { - NodeRef ref = getAuthorityOrNull(name); - return ref != null; - } - - public void addAuthority(Collection parentNames, String childName) - { - Set parentRefs = new HashSet(parentNames.size() * 2); - AuthorityType authorityType = AuthorityType.getAuthorityType(childName); - boolean isUser = authorityType.equals(AuthorityType.USER); - boolean notUserOrGroup = !isUser && !authorityType.equals(AuthorityType.GROUP); - for (String parentName : parentNames) - { - NodeRef parentRef = getAuthorityOrNull(parentName); - if (parentRef == null) - { - throw new UnknownAuthorityException("An authority was not found for " + parentName); - } - if (notUserOrGroup - && !(authorityType.equals(AuthorityType.ROLE) && AuthorityType.getAuthorityType(parentName).equals( - AuthorityType.ROLE))) - { - throw new AlfrescoRuntimeException("Authorities of the type " + authorityType - + " may not be added to other authorities"); - } - removeCachedChildAuthorities(parentRef); - parentRefs.add(parentRef); - } - NodeRef childRef = getAuthorityOrNull(childName); - - if (childRef == null) - { - throw new UnknownAuthorityException("An authority was not found for " + childName); - } - - // Normalize the user name if necessary - if (isUser) - { - childName = (String) nodeService.getProperty(childRef, ContentModel.PROP_USERNAME); - } - - nodeService.addChild(parentRefs, childRef, ContentModel.ASSOC_MEMBER, QName.createQName("cm", childName, - namespacePrefixResolver)); - if (isUser) - { - userAuthorityCache.remove(childName); - } - else - { - userAuthorityCache.clear(); - } - } - - public void createAuthority(String name, String authorityDisplayName, Set authorityZones) - { - HashMap props = new HashMap(); - props.put(ContentModel.PROP_AUTHORITY_NAME, name); - props.put(ContentModel.PROP_AUTHORITY_DISPLAY_NAME, authorityDisplayName); - NodeRef childRef; - NodeRef authorityContainerRef = getAuthorityContainer(); - childRef = nodeService.createNode(authorityContainerRef, ContentModel.ASSOC_CHILDREN, QName.createQName("cm", name, namespacePrefixResolver), - ContentModel.TYPE_AUTHORITY_CONTAINER, props).getChildRef(); - if (authorityZones != null) - { - Set zoneRefs = new HashSet(authorityZones.size() * 2); - String currentUserDomain = tenantService.getCurrentUserDomain(); - for (String authorityZone : authorityZones) - { - zoneRefs.add(getOrCreateZone(authorityZone)); - zoneAuthorityCache.remove(new Pair(currentUserDomain, authorityZone)); - } - zoneAuthorityCache.remove(new Pair(currentUserDomain, null)); - nodeService.addChild(zoneRefs, childRef, ContentModel.ASSOC_IN_ZONE, QName.createQName("cm", name, namespacePrefixResolver)); - } - authorityLookupCache.put(cacheKey(name), childRef); - } - - private NodeRef cacheKey(NodeRef nodeRef) - { - return tenantService.getName(nodeRef); - } - - private Pair cacheKey(String authorityName) - { - String tenantDomain = AuthorityType.getAuthorityType(authorityName) == AuthorityType.USER ? tenantService.getDomain(authorityName) : tenantService.getCurrentUserDomain(); - return new Pair(tenantDomain, authorityName); - } - - public void deleteAuthority(String name) - { - NodeRef nodeRef = getAuthorityOrNull(name); - if (nodeRef == null) - { - throw new UnknownAuthorityException("An authority was not found for " + name); - } - String currentUserDomain = tenantService.getCurrentUserDomain(); - for (String authorityZone : getAuthorityZones(name)) - { - zoneAuthorityCache.remove(new Pair(currentUserDomain, authorityZone)); - } - zoneAuthorityCache.remove(new Pair(currentUserDomain, null)); - removeParentsFromChildAuthorityCache(nodeRef); - authorityLookupCache.remove(cacheKey(name)); - userAuthorityCache.clear(); - - nodeService.deleteNode(nodeRef); - } - - // Get authorities by type and/or zone (both cannot be null) - public PagingResults getAuthorities(AuthorityType type, String zoneName, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest) - { - ParameterCheck.mandatory("pagingRequest", pagingRequest); - - if ((type == null) && (zoneName == null)) - { - throw new IllegalArgumentException("Type and/or zoneName required - both cannot be null"); - } - - if ((zoneName == null) && (type.equals(AuthorityType.USER))) - { - return getUserAuthoritiesImpl(displayNameFilter, sortByDisplayName, sortAscending, pagingRequest); - } - - NodeRef containerRef = null; - if (zoneName != null) - { - containerRef = getZone(zoneName); - if (containerRef == null) - { - throw new UnknownAuthorityException("A zone was not found for " + zoneName); - } - } - else - { - containerRef = getAuthorityContainer(); - } - - return getAuthoritiesImpl(type, containerRef, displayNameFilter, sortByDisplayName, sortAscending, pagingRequest); - } - - private PagingResults getAuthoritiesImpl(AuthorityType type, NodeRef containerRef, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest) - { - Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null); - - if (type != null) - { - switch (type) - { - case GROUP: - case ROLE: - case USER: - // drop through - break; - default: - throw new UnsupportedOperationException("Unexpected authority type: "+type); - } - } - - // get canned query - GetAuthoritiesCannedQueryFactory getAuthoritiesCannedQueryFactory = (GetAuthoritiesCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_AUTHS_LIST); - CannedQuery cq = getAuthoritiesCannedQueryFactory.getCannedQuery(type, containerRef, displayNameFilter, sortByDisplayName, sortAscending, pagingRequest); - - // execute canned query - final CannedQueryResults results = cq.execute(); - - PagingResults finalResults = new PagingResults() - { - @Override - public String getQueryExecutionId() - { - return results.getQueryExecutionId(); - } - @Override - public List getPage() - { - List auths = new ArrayList(results.getPageCount()); - for (AuthorityInfo authInfo : results.getPage()) - { - auths.add(authInfo.getAuthorityName()); - } - return auths; - } - @Override - public boolean hasMoreItems() - { - return results.hasMoreItems(); - } - @Override - public Pair getTotalResultCount() - { - return results.getTotalResultCount(); - } - }; - - if (start != null) - { - int cnt = finalResults.getPage().size(); - int skipCount = pagingRequest.getSkipCount(); - int maxItems = pagingRequest.getMaxItems(); - boolean hasMoreItems = finalResults.hasMoreItems(); - int pageNum = (skipCount / maxItems) + 1; - - logger.debug("getAuthoritiesByType: "+cnt+" items in "+(System.currentTimeMillis()-start)+" msecs [type="+type+",pageNum="+pageNum+",skip="+skipCount+",max="+maxItems+",hasMorePages="+hasMoreItems+",filter="+displayNameFilter+"]"); - } - - return finalResults; - } - - // delegate to PersonService.getPeople - private PagingResults getUserAuthoritiesImpl(String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest) - { - List> filter = null; - if (displayNameFilter != null) - { - filter = new ArrayList>(); - filter.add(new Pair(ContentModel.PROP_USERNAME, displayNameFilter)); - } - - List> sort = null; - if (sortByDisplayName) - { - sort = new ArrayList>(); - sort.add(new Pair(ContentModel.PROP_USERNAME, sortAscending)); - } - - final PagingResults ppr = personService.getPeople(filter, true, sort, pagingRequest); - - List result = ppr.getPage(); - final List auths = new ArrayList(result.size()); - - for (PersonInfo person : result) - { - auths.add(person.getUserName()); - } - - return new PagingResults() - { - @Override - public String getQueryExecutionId() - { - return ppr.getQueryExecutionId(); - } - @Override - public List getPage() - { - return auths; - } - @Override - public boolean hasMoreItems() - { - return ppr.hasMoreItems(); - } - @Override - public Pair getTotalResultCount() - { - return ppr.getTotalResultCount(); - } - }; - } - - public Set getRootAuthorities(AuthorityType type, String zoneName) - { - NodeRef container = (zoneName == null ? getAuthorityContainer() : getZone(zoneName)); - if (container == null) - { - // The zone doesn't even exist so there are no root authorities - return Collections.emptySet(); - } - - return getRootAuthoritiesUnderContainer(container, type); - } - - public Set findAuthorities(AuthorityType type, String parentAuthority, boolean immediate, - String displayNamePattern, String zoneName) - { - Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null); - - Pattern pattern = displayNamePattern == null ? null : Pattern.compile(SearchLanguageConversion.convert( - SearchLanguageConversion.DEF_LUCENE, SearchLanguageConversion.DEF_REGEX, displayNamePattern), - Pattern.CASE_INSENSITIVE); - - // Use SQL to determine root authorities - Set rootAuthorities = null; - if (parentAuthority == null && immediate) - { - rootAuthorities = getRootAuthorities(type, zoneName); - if (pattern == null) - { - if (start != null) - { - logger.debug("findAuthorities (rootAuthories): "+rootAuthorities.size()+" items in "+(System.currentTimeMillis()-start)+" msecs [type="+type+",zone="+zoneName+"]"); - } - - return rootAuthorities; - } - } - - // Use a Lucene search for other criteria - Set authorities = new TreeSet(); - SearchParameters sp = new SearchParameters(); - sp.addStore(this.storeRef); - sp.setLanguage("lucene"); - StringBuilder query = new StringBuilder(500); - if (type == null || type == AuthorityType.USER) - { - if (type == null) - { - query.append("(("); - } - query.append("TYPE:\"").append(ContentModel.TYPE_PERSON).append("\""); - if (displayNamePattern != null) - { - query.append(" AND @").append( - AbstractLuceneQueryParser.escape("{" + ContentModel.PROP_USERNAME.getNamespaceURI() + "}" - + ISO9075.encode(ContentModel.PROP_USERNAME.getLocalName()))).append(":\"").append( - AbstractLuceneQueryParser.escape(displayNamePattern)).append("\""); - - } - if (type == null) - { - query.append(") OR ("); - } - } - if (type != AuthorityType.USER) - { - query.append("TYPE:\"").append(ContentModel.TYPE_AUTHORITY_CONTAINER).append("\""); - if (displayNamePattern != null) - { - query.append(" AND ("); - if (!displayNamePattern.startsWith("*")) - { - // Allow for the appropriate type prefix in the authority name - Collection authorityTypes = type == null ? SEARCHABLE_AUTHORITY_TYPES - : Collections.singleton(type); - boolean first = true; - for (AuthorityType subType: authorityTypes) - { - if (first) - { - first = false; - } - else - { - query.append(" OR "); - } - query.append("@").append( - AbstractLuceneQueryParser.escape("{" + ContentModel.PROP_AUTHORITY_NAME.getNamespaceURI() + "}" - + ISO9075.encode(ContentModel.PROP_AUTHORITY_NAME.getLocalName()))).append(":\""); - query.append(getName(subType, AbstractLuceneQueryParser.escape(displayNamePattern))).append("\""); - - } - } - else - { - query.append("@").append( - AbstractLuceneQueryParser.escape("{" + ContentModel.PROP_AUTHORITY_NAME.getNamespaceURI() + "}" - + ISO9075.encode(ContentModel.PROP_AUTHORITY_NAME.getLocalName()))).append(":\""); - query.append(getName(type, AbstractLuceneQueryParser.escape(displayNamePattern))).append("\""); - } - query.append(" OR @").append( - AbstractLuceneQueryParser.escape("{" + ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getNamespaceURI() + "}" - + ISO9075.encode(ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getLocalName()))).append( - ":\"").append(AbstractLuceneQueryParser.escape(displayNamePattern)).append("\")"); - } - if (type == null) - { - query.append("))"); - } - } - if (parentAuthority != null) - { - if(immediate) - { - // use PARENT - NodeRef parentAuthorityNodeRef = getAuthorityNodeRefOrNull(parentAuthority); - if(parentAuthorityNodeRef != null) - { - query.append(" AND PARENT:\"").append(AbstractLuceneQueryParser.escape(parentAuthorityNodeRef.toString())).append("\""); - } - else - { - throw new UnknownAuthorityException("An authority was not found for " + parentAuthority); - } - } - else - { - // use PATH - query.append(" AND PATH:\"/sys:system/sys:authorities/cm:").append(ISO9075.encode(parentAuthority)); - query.append("//*\""); - } - } - if (zoneName != null) - { - // Zones are all direct links to those within so it is safe to use PARENT to look them up - NodeRef zoneNodeRef = getZone(zoneName); - if (zoneNodeRef != null) - { - query.append(" AND PARENT:\"").append(AbstractLuceneQueryParser.escape(zoneNodeRef.toString())).append("\""); - } - else - { - throw new UnknownAuthorityException("A zone was not found for " + zoneName); - } - } - sp.setQuery(query.toString()); - sp.setMaxItems(100); - ResultSet rs = null; - try - { - rs = searchService.query(sp); - - for (ResultSetRow row : rs) - { - NodeRef nodeRef = row.getNodeRef(); - QName idProp = dictionaryService.isSubClass(nodeService.getType(nodeRef), - ContentModel.TYPE_AUTHORITY_CONTAINER) ? ContentModel.PROP_AUTHORITY_NAME - : ContentModel.PROP_USERNAME; - addAuthorityNameIfMatches(authorities, DefaultTypeConverter.INSTANCE.convert(String.class, nodeService - .getProperty(nodeRef, idProp)), type, pattern); - } - - // If we asked for root authorities, we must do an intersection with the set of root authorities - if (rootAuthorities != null) - { - authorities.retainAll(rootAuthorities); - } - - if (start != null) - { - logger.debug("findAuthorities: "+authorities.size()+" items in "+(System.currentTimeMillis()-start)+" msecs [type="+type+",zone="+zoneName+",parent="+parentAuthority+",immediate="+immediate+",filter="+displayNamePattern+"]"); - } - - return authorities; - } - finally - { - if (rs != null) - { - rs.close(); - } - } - } - - public Set getContainedAuthorities(AuthorityType type, String parentName, boolean immediate) - { - AuthorityType parentAuthorityType = AuthorityType.getAuthorityType(parentName); - if (parentAuthorityType == AuthorityType.USER) - { - // Users never contain other authorities - return Collections. emptySet(); - } - else - { - NodeRef nodeRef = getAuthorityOrNull(parentName); - if (nodeRef == null) - { - throw new UnknownAuthorityException("An authority was not found for " + parentName); - } - - Set authorities = new TreeSet(); - listAuthorities(type, nodeRef, authorities, false, !immediate, false); - return authorities; - } - } - - public void removeAuthority(String parentName, String childName) - { - NodeRef parentRef = getAuthorityOrNull(parentName); - if (parentRef == null) - { - throw new UnknownAuthorityException("An authority was not found for " + parentName); - } - NodeRef childRef = getAuthorityOrNull(childName); - if (childRef == null) - { - throw new UnknownAuthorityException("An authority was not found for " + childName); - } - nodeService.removeChild(parentRef, childRef); - removeCachedChildAuthorities(parentRef); - if (AuthorityType.getAuthorityType(childName) == AuthorityType.USER) - { - userAuthorityCache.remove(childName); - } - else - { - userAuthorityCache.clear(); - } - } - - public Set getContainingAuthorities(AuthorityType type, String name, boolean immediate) - { - // Optimize for the case where we want all the authorities that a user belongs to - if (!immediate && AuthorityType.getAuthorityType(name) == AuthorityType.USER) - { - // Get the unfiltered set of authorities from the cache or generate it - Set authorities = userAuthorityCache.get(name); - if (authorities == null) - { - authorities = new TreeSet(); - listAuthorities(null, name, authorities, true, true); - userAuthorityCache.put(name, authorities); - } - // If we wanted the unfiltered set we are done - if (type == null) - { - return authorities; - } - // Apply the filtering by type - Set filteredAuthorities = new TreeSet(); - for (String authority : authorities) - { - addAuthorityNameIfMatches(filteredAuthorities, authority, type); - } - return filteredAuthorities; - } - // Otherwise, crawl the DB for the answer - else - { - Set authorities = new TreeSet(); - listAuthorities(type, name, authorities, true, !immediate); - return authorities; - } - } - - public Set getContainingAuthoritiesInZone(AuthorityType type, String authority, final String zoneName, AuthorityFilter filter, int size) - { - // Retrieved the cached 'sample' of authorities in the zone - String currentUserDomain = tenantService.getCurrentUserDomain(); - Pair cacheKey = new Pair(currentUserDomain, zoneName); - List zoneAuthorities = zoneAuthorityCache.get(cacheKey); - final int maxToProcess = Math.max(size, zoneAuthoritySampleSize); - if (zoneAuthorities == null) - { - zoneAuthorities = AuthenticationUtil.runAs(new RunAsWork>() - { - @Override - public List doWork() throws Exception - { - NodeRef root = zoneName == null ? getAuthorityContainer() : getZone(zoneName); - if (root == null) - { - return Collections.emptyList(); - } - return nodeService.getChildAssocs(root, null, null, maxToProcess, false); - } - }, tenantService.getDomainUser(AuthenticationUtil.getSystemUserName(), currentUserDomain)); - zoneAuthorityCache.put(cacheKey, zoneAuthorities); - } - - // Now search each for the required authority. If the number of results is greater than or close to the size - // limit, then this will be the most efficient route - Set result = new TreeSet(); - final int maxResults = size > 0 ? size : Integer.MAX_VALUE; - int hits = 0, processed = 0; - for (ChildAssociationRef groupAssoc : zoneAuthorities) - { - String containing = groupAssoc.getQName().getLocalName(); - AuthorityType containingType = AuthorityType.getAuthorityType(containing); - processed++; - // Cache the authority by key, if appropriate - switch (containingType) - { - case USER: - case ADMIN: - case GUEST: - break; - default: - Pair containingKey = cacheKey(containing); - if (!authorityLookupCache.contains(containingKey)) - { - authorityLookupCache.put(containingKey, groupAssoc.getChildRef()); - } - } - if ((type == null || containingType == type) - && (authority == null || isAuthorityContained(groupAssoc.getChildRef(), authority)) - && (filter == null || filter.includeAuthority(containing))) - { - result.add(containing); - if (++hits == maxResults) - { - break; - } - } - - // If this top down search is not providing an adequate hit count then resort to a naiive unlimited search - if (processed >= maxToProcess) - { - Set unfilteredResult; - boolean filterZone; - if (authority == null) - { - unfilteredResult = new HashSet(getAuthorities(type, zoneName, null, false, true, new PagingRequest(0, filter == null ? maxResults : Integer.MAX_VALUE, null)).getPage()); - if (filter == null) - { - return unfilteredResult; - } - filterZone = false; - } - else - { - unfilteredResult = getContainingAuthorities(type, authority, false); - filterZone = zoneName != null; - } - Set newResult = new TreeSet(result); - int i=newResult.size(); - for (String container : unfilteredResult) - { - // Do not call the filter multiple times on the same result in case it is 'stateful' - if (!result.contains(container) && (filter == null || filter.includeAuthority(container)) - && (!filterZone || getAuthorityZones(container).contains(zoneName))) - { - newResult.add(container); - if (++i >= maxResults) - { - break; - } - } - } - result = newResult; - break; - } - } - return result; - } - - public String getShortName(String name) - { - AuthorityType type = AuthorityType.getAuthorityType(name); - if (type.isFixedString()) - { - return ""; - } - else if (type.isPrefixed()) - { - return name.substring(type.getPrefixString().length()); - } - else - { - return name; - } - } - - public String getName(AuthorityType type, String shortName) - { - if (type.isFixedString()) - { - return type.getFixedString(); - } - else if (type.isPrefixed()) - { - return type.getPrefixString() + shortName; - } - else - { - return shortName; - } - } - - private void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type) - { - if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type) && !getAuthorityZones(authorityName).contains("APP.RM")) + if (isAuthorityNameMatching(authorities, authorityName, type)) { authorities.add(authorityName); } } - private void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern) + protected void addAuthorityNameIfMatches(Set authorities, String authorityName, AuthorityType type, Pattern pattern) { - if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type) && !getAuthorityZones(authorityName).contains("APP.RM")) + if (isAuthorityNameMatching(authorities, authorityName, type)) { if (pattern == null) { @@ -934,475 +69,13 @@ public class RMAuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Bef } } - private void listAuthorities(AuthorityType type, String name, Set authorities, boolean parents, boolean recursive) + private boolean isAuthorityNameMatching(Set authorities, String authorityName, AuthorityType type) { - AuthorityType localType = AuthorityType.getAuthorityType(name); - if (localType.equals(AuthorityType.GUEST)) + boolean isMatching = false; + if (type == null || AuthorityType.getAuthorityType(authorityName).equals(type) && !getAuthorityZones(authorityName).contains("APP.RM")) { - // Nothing to do - } - else - { - NodeRef ref = getAuthorityOrNull(name); - - if (ref != null) - { - listAuthorities(type, ref, authorities, parents, recursive, false); - } - else if (!localType.equals(AuthorityType.USER)) - { - // Don't worry about missing person objects. It might be the system user or a user yet to be - // auto-created - throw new UnknownAuthorityException("An authority was not found for " + name); - } + isMatching = true; } + return isMatching; } - - private void listAuthorities(AuthorityType type, NodeRef nodeRef, Set authorities, boolean parents, boolean recursive, boolean includeNode) - { - if (includeNode) - { - String authorityName = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService - .getProperty(nodeRef, dictionaryService.isSubClass(nodeService.getType(nodeRef), - ContentModel.TYPE_AUTHORITY_CONTAINER) ? ContentModel.PROP_AUTHORITY_NAME - : ContentModel.PROP_USERNAME)); - addAuthorityNameIfMatches(authorities, authorityName, type); - } - - // Loop over children if we want immediate children or are in recursive mode - if (!includeNode || recursive) - { - if (parents) - { - List cars = nodeService.getParentAssocs(nodeRef, ContentModel.ASSOC_MEMBER, RegexQNamePattern.MATCH_ALL); - - for (ChildAssociationRef car : cars) - { - listAuthorities(type, car.getParentRef(), authorities, true, recursive, true); - } - } - else - { - List cars = getCachedChildAuthorities(nodeRef); - if (cars == null) - { - cars = nodeService.getChildAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, - RegexQNamePattern.MATCH_ALL, false); - if (!cars.isEmpty() && cars.get(0).getTypeQName().equals(ContentModel.ASSOC_MEMBER)) - { - putCachedChildAuthorities(nodeRef, cars); - } - } - - // Take advantage of the fact that the authority name is on the child association - for (ChildAssociationRef car : cars) - { - String childName = car.getQName().getLocalName(); - AuthorityType childType = AuthorityType.getAuthorityType(childName); - addAuthorityNameIfMatches(authorities, childName, type); - if (recursive && childType != AuthorityType.USER) - { - listAuthorities(type, car.getChildRef(), authorities, false, true, false); - } - } - } - } - } - - - // Take advantage of the fact that the authority name is on the child association - public boolean isAuthorityContained(NodeRef authorityNodeRef, String authorityToFind) - { - List cars = getCachedChildAuthorities(authorityNodeRef); - if (cars == null) - { - cars = nodeService.getChildAssocs(authorityNodeRef, RegexQNamePattern.MATCH_ALL, - RegexQNamePattern.MATCH_ALL, false); - putCachedChildAuthorities(authorityNodeRef, cars); - } - - // Loop over children recursively to find authorityToFind - for (ChildAssociationRef car : cars) - { - String authorityName = car.getQName().getLocalName(); - if (authorityToFind.equals(authorityName) - || AuthorityType.getAuthorityType(authorityName) != AuthorityType.USER - && isAuthorityContained(car.getChildRef(), authorityToFind)) - { - return true; - } - } - return false; - } - - private void removeParentsFromChildAuthorityCache(NodeRef nodeRef) - { - for (ChildAssociationRef car: nodeService.getParentAssocs(nodeRef)) - { - NodeRef parentRef = car.getParentRef(); - if (dictionaryService.isSubClass(nodeService.getType(parentRef), ContentModel.TYPE_AUTHORITY_CONTAINER)) - { - removeCachedChildAuthorities(parentRef); - } - } - } - - private NodeRef getAuthorityOrNull(final String name) - { - try - { - if (AuthorityType.getAuthorityType(name).equals(AuthorityType.USER)) - { - return personService.getPerson(name, false); - } - else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.GUEST) || AuthorityType.getAuthorityType(name).equals(AuthorityType.ADMIN)) - { - return null; - } - else - { - Pair cacheKey = cacheKey(name); - NodeRef result = authorityLookupCache.get(cacheKey); - if (result == null) - { - List results = nodeService.getChildAssocs(getAuthorityContainer(), - ContentModel.ASSOC_CHILDREN, QName.createQName("cm", name, namespacePrefixResolver), false); - result = results.isEmpty() ? NULL_NODEREF :results.get(0).getChildRef(); - authorityLookupCache.put(cacheKey, result); - } - return result == NULL_NODEREF ? null : result; - } - } - catch (NoSuchPersonException e) - { - return null; - } - } - - /** - * @return Returns the authority container, which must exist - */ - private NodeRef getAuthorityContainer() - { - return getSystemContainer(qnameAssocAuthorities); - } - - /** - * @return Returns the zone container, which must exist - */ - private NodeRef getZoneContainer() - { - return getSystemContainer(qnameAssocZones); - } - - /** - * Return the system container for the specified assoc name. - * The containers are cached in a thread safe Tenant aware cache. - * - * @param assocQName - * - * @return System container, which must exist - */ - private NodeRef getSystemContainer(QName assocQName) - { - final String cacheKey = tenantService.getCurrentUserDomain() + assocQName.toString(); - NodeRef systemContainerRef = systemContainerRefs.get(cacheKey); - if (systemContainerRef == null) - { - NodeRef rootNodeRef = nodeService.getRootNode(this.storeRef); - List results = nodeService.getChildAssocs(rootNodeRef, RegexQNamePattern.MATCH_ALL, qnameAssocSystem, false); - if (results.size() == 0) - { - throw new AlfrescoRuntimeException("Required system path not found: " + qnameAssocSystem); - } - NodeRef sysNodeRef = results.get(0).getChildRef(); - results = nodeService.getChildAssocs(sysNodeRef, RegexQNamePattern.MATCH_ALL, assocQName, false); - if (results.size() == 0) - { - throw new AlfrescoRuntimeException("Required path not found: " + assocQName); - } - systemContainerRef = results.get(0).getChildRef(); - systemContainerRefs.put(cacheKey, systemContainerRef); - } - return systemContainerRef; - } - - public NodeRef getAuthorityNodeRefOrNull(String name) - { - return getAuthorityOrNull(name); - } - - public String getAuthorityName(NodeRef authorityRef) - { - String name = null; - if (nodeService.exists(authorityRef)) - { - QName type = nodeService.getType(authorityRef); - if (dictionaryService.isSubClass(type, ContentModel.TYPE_AUTHORITY_CONTAINER)) - { - name = (String) nodeService.getProperty(authorityRef, ContentModel.PROP_AUTHORITY_NAME); - } - else if (dictionaryService.isSubClass(type, ContentModel.TYPE_PERSON)) - { - name = (String) nodeService.getProperty(authorityRef, ContentModel.PROP_USERNAME); - } - } - return name; - } - - public String getAuthorityDisplayName(String authorityName) - { - NodeRef ref = getAuthorityOrNull(authorityName); - if (ref == null) - { - return null; - } - Serializable value = nodeService.getProperty(ref, ContentModel.PROP_AUTHORITY_DISPLAY_NAME); - if (value == null) - { - return null; - } - return DefaultTypeConverter.INSTANCE.convert(String.class, value); - } - - public void setAuthorityDisplayName(String authorityName, String authorityDisplayName) - { - NodeRef ref = getAuthorityOrNull(authorityName); - if (ref == null) - { - return; - } - nodeService.setProperty(ref, ContentModel.PROP_AUTHORITY_DISPLAY_NAME, authorityDisplayName); - - } - - public NodeRef getOrCreateZone(String zoneName) - { - return getOrCreateZone(zoneName, true); - } - - private NodeRef getOrCreateZone(String zoneName, boolean create) - { - NodeRef zoneContainerRef = getZoneContainer(); - QName zoneQName = QName.createQName("cm", zoneName, namespacePrefixResolver); - List results = nodeService.getChildAssocs(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName, false); - if (results.isEmpty()) - { - if (create) - { - HashMap props = new HashMap(); - props.put(ContentModel.PROP_NAME, zoneName); - return nodeService.createNode(zoneContainerRef, ContentModel.ASSOC_CHILDREN, zoneQName, ContentModel.TYPE_ZONE, props).getChildRef(); - } - else - { - return null; - } - } - else - { - return results.get(0).getChildRef(); - } - } - - public NodeRef getZone(String zoneName) - { - return getOrCreateZone(zoneName, false); - } - - public Set getAuthorityZones(String name) - { - Set zones = new TreeSet(); - NodeRef childRef = getAuthorityOrNull(name); - if (childRef == null) - { - return null; - } - List results = nodeService.getParentAssocs(childRef, ContentModel.ASSOC_IN_ZONE, RegexQNamePattern.MATCH_ALL); - if (results.isEmpty()) - { - return zones; - } - - for (ChildAssociationRef current : results) - { - NodeRef zoneRef = current.getParentRef(); - Serializable value = nodeService.getProperty(zoneRef, ContentModel.PROP_NAME); - if (value == null) - { - continue; - } - else - { - String zone = DefaultTypeConverter.INSTANCE.convert(String.class, value); - zones.add(zone); - } - } - return zones; - } - - public Set getAllAuthoritiesInZone(String zoneName, AuthorityType type) - { - NodeRef zoneRef = getZone(zoneName); - if (zoneRef == null) - { - return Collections.emptySet(); - } - return new HashSet(getAuthoritiesImpl(type, zoneRef, null, false, false, new PagingRequest(0, Integer.MAX_VALUE, null)).getPage()); - } - - public void addAuthorityToZones(String authorityName, Set zones) - { - if ((zones != null) && (zones.size() > 0)) - { - Set zoneRefs = new HashSet(zones.size() * 2); - for (String authorityZone : zones) - { - zoneRefs.add(getOrCreateZone(authorityZone)); - } - NodeRef authRef = getAuthorityOrNull(authorityName); - if (authRef != null) - { - // Normalize the user name if necessary - if (AuthorityType.getAuthorityType(authorityName) == AuthorityType.USER) - { - authorityName = (String) nodeService.getProperty(authRef, ContentModel.PROP_USERNAME); - } - - nodeService.addChild(zoneRefs, authRef, ContentModel.ASSOC_IN_ZONE, QName.createQName("cm", authorityName, namespacePrefixResolver)); - } - } - } - - public void removeAuthorityFromZones(String authorityName, Set zones) - { - if ((zones != null) && (zones.size() > 0)) - { - NodeRef authRef = getAuthorityOrNull(authorityName); - List results = nodeService.getParentAssocs(authRef, ContentModel.ASSOC_IN_ZONE, RegexQNamePattern.MATCH_ALL); - for (ChildAssociationRef current : results) - { - NodeRef zoneRef = current.getParentRef(); - Serializable value = nodeService.getProperty(zoneRef, ContentModel.PROP_NAME); - if (value == null) - { - continue; - } - else - { - String testZone = DefaultTypeConverter.INSTANCE.convert(String.class, value); - if (zones.contains(testZone)) - { - nodeService.removeChildAssociation(current); - } - } - } - } - } - - private Set getRootAuthoritiesUnderContainer(NodeRef container, AuthorityType type) - { - if (type != null && type.equals(AuthorityType.USER)) - { - return Collections. emptySet(); - } - Collection childRefs = nodeService.getChildAssocsWithoutParentAssocsOfType(container, ContentModel.ASSOC_MEMBER); - Set authorities = new TreeSet(); - for (ChildAssociationRef childRef : childRefs) - { - addAuthorityNameIfMatches(authorities, childRef.getQName().getLocalName(), type); - } - return authorities; - } - - // Listen out for person removals so that we can clear cached authorities - public void beforeDeleteNode(NodeRef nodeRef) - { - userAuthorityCache.remove(getAuthorityName(nodeRef)); - removeParentsFromChildAuthorityCache(nodeRef); - } - - public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) - { - boolean isAuthority = dictionaryService.isSubClass(nodeService.getType(nodeRef), - ContentModel.TYPE_AUTHORITY_CONTAINER); - QName idProp = isAuthority ? ContentModel.PROP_AUTHORITY_NAME : ContentModel.PROP_USERNAME; - String authBefore = DefaultTypeConverter.INSTANCE.convert(String.class, before.get(idProp)); - if (authBefore == null) - { - // Node has just been created; nothing to do - return; - } - String authAfter = DefaultTypeConverter.INSTANCE.convert(String.class, after.get(idProp)); - if (!EqualsHelper.nullSafeEquals(authBefore, authAfter)) - { - if (AlfrescoTransactionSupport.getResource(PersonServiceImpl.KEY_ALLOW_UID_UPDATE) != null || authBefore.equalsIgnoreCase(authAfter)) - { - if (isAuthority) - { - if (authBefore != null) - { - // Fix any ACLs - aclDao.renameAuthority(authBefore, authAfter); - } - - // Fix primary association local name - QName newAssocQName = QName.createQName("cm", authAfter, namespacePrefixResolver); - ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); - nodeService.moveNode(nodeRef, assoc.getParentRef(), assoc.getTypeQName(), newAssocQName); - - // Fix other non-case sensitive parent associations - QName oldAssocQName = QName.createQName("cm", authBefore, namespacePrefixResolver); - newAssocQName = QName.createQName("cm", authAfter, namespacePrefixResolver); - for (ChildAssociationRef parent : nodeService.getParentAssocs(nodeRef)) - { - if (!parent.isPrimary() && parent.getQName().equals(oldAssocQName)) - { - nodeService.removeChildAssociation(parent); - nodeService.addChild(parent.getParentRef(), parent.getChildRef(), parent.getTypeQName(), - newAssocQName); - } - } - authorityLookupCache.clear(); - - // Cache is out of date - userAuthorityCache.clear(); - } - else - { - userAuthorityCache.remove(authBefore); - } - removeParentsFromChildAuthorityCache(nodeRef); - } - else - { - throw new UnsupportedOperationException("The name of an authority can not be changed"); - } - } - } - - public void init() - { - // Listen out for person removals so that we can clear cached authorities - this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), ContentModel.TYPE_PERSON, new JavaBehaviour( - this, "beforeDeleteNode")); - // Listen out for updates to persons and authority containers to handle renames - this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onUpdateProperties"), ContentModel.TYPE_AUTHORITY, new JavaBehaviour( - this, "onUpdateProperties")); - } - - private List getCachedChildAuthorities(NodeRef parentNodeRef) - { - return childAuthorityCache.get(cacheKey(parentNodeRef)); - } - - private void removeCachedChildAuthorities(NodeRef parentNodeRef) - { - childAuthorityCache.remove(cacheKey(parentNodeRef)); - } - - private void putCachedChildAuthorities(NodeRef parentNodeRef, List children) - { - childAuthorityCache.put(cacheKey(parentNodeRef), children); - } } diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java index 500b66263a..5a53b3909a 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmClassesGet.java @@ -196,7 +196,7 @@ public class RmClassesGet extends DictionaryWebServiceBase implements RecordsMan } List classDefinitions = new ArrayList(classdef.values()); - Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator()); + Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice)); model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions); model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values()); model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values()); diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java index f19ffb9a23..3192de95a7 100644 --- a/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java +++ b/rm-server/source/java/org/alfresco/repo/web/scripts/dictionary/RmPropertiesGet.java @@ -147,7 +147,7 @@ public class RmPropertiesGet extends DictionaryWebServiceBase implements Records } // Order property definitions by title - Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator()); + Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator(dictionaryservice)); // Pass list of property definitions to template Map model = new HashMap(); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementAdminServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementAdminServiceImplTest.java index b10067fb8a..3a93622fa6 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementAdminServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/RecordsManagementAdminServiceImplTest.java @@ -58,45 +58,45 @@ import org.springframework.util.CollectionUtils; /** * This test class tests the definition and use of a custom RM elements at the Java services layer. - * + * * @author Neil McErlean, janv, Roy Wetherall */ -public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase +public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase implements RecordsManagementModel, BeforeCreateReference, OnCreateReference { - + private final static long testRunID = System.currentTimeMillis(); - - private List createdCustomProperties; + + private List createdCustomProperties; private List madeCustomisable; - + /** * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setUp() */ @Override - protected void setUp() throws Exception - { + protected void setUp() throws Exception + { createdCustomProperties = new ArrayList(); madeCustomisable = new ArrayList(); super.setUp(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#setupTestData() */ @Override - protected void setupTestData() + protected void setupTestData() { - super.setupTestData(); + super.setupTestData(); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#tearDown() */ @Override - protected void tearDown() throws Exception + protected void tearDown() throws Exception { retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() { @@ -105,24 +105,24 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { // As system user AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - - for (QName createdCustomProperty : createdCustomProperties) + + for (QName createdCustomProperty : createdCustomProperties) { adminService.removeCustomPropertyDefinition(createdCustomProperty); } - - for (QName customisable : madeCustomisable) + + for (QName customisable : madeCustomisable) { adminService.unmakeCustomisable(customisable); } - + return null; } - }); - + }); + super.tearDown(); } - + /** * @see RecordsManagementAdminService#getCustomisable() */ @@ -139,17 +139,17 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase assertTrue(list.containsAll( CollectionUtils.arrayToList(new QName[] { - ASPECT_RECORD, - TYPE_RECORD_FOLDER, + ASPECT_RECORD, + TYPE_RECORD_FOLDER, TYPE_NON_ELECTRONIC_DOCUMENT, TYPE_RECORD_CATEGORY }))); - + return null; } }); } - + /** * @see RecordsManagementAdminService#isCustomisable(QName) */ @@ -164,12 +164,12 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase assertFalse(adminService.isCustomisable(ASPECT_DUBLINCORE)); assertTrue(adminService.isCustomisable(TYPE_RECORD_FOLDER)); assertTrue(adminService.isCustomisable(ASPECT_RECORD)); - + return null; } }); } - + /** * @see RecordsManagementAdminService#existsCustomProperty(QName) * @see RecordsManagementAdminService#addCustomPropertyDefinition(QName, QName, String, QName, String, String, String, boolean, boolean, boolean, QName) @@ -182,66 +182,66 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { @Override public QName run() throws Exception - { + { // Check the property does not exist assertFalse(adminService.existsCustomProperty(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"))); - + return adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), - ASPECT_RECORD, - "Label1", - DataTypeDefinition.TEXT, - "Title", + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), + ASPECT_RECORD, + "Label1", + DataTypeDefinition.TEXT, + "Title", "Description"); } - + @Override - public void test(QName result) throws Exception + public void test(QName result) throws Exception { try - { + { // Check the property QName is correct assertNotNull(result); assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), result); assertTrue(adminService.existsCustomProperty(result)); - + // Check that property is available as a custom property Map propDefs = adminService.getCustomPropertyDefinitions(ASPECT_RECORD); assertNotNull(propDefs); assertTrue(propDefs.containsKey(result)); - + // Check the property definition PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); + assertNotNull(propDef); assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription()); - assertEquals("Label1", propDef.getTitle()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label1", propDef.getTitle(dictionaryService)); } finally { // Store the created property for cleanup later createdCustomProperties.add(result); - } + } } }); - + // Add property to record (no id, short version) doTestInTransaction(new Test() { @Override public QName run() throws Exception - { + { return adminService.addCustomPropertyDefinition( - null, - ASPECT_RECORD, - "Label2", - DataTypeDefinition.TEXT, - "Title", + null, + ASPECT_RECORD, + "Label2", + DataTypeDefinition.TEXT, + "Title", "Description"); } - + @Override - public void test(QName result) throws Exception + public void test(QName result) throws Exception { try { @@ -249,83 +249,83 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase assertNotNull(result); assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); assertTrue(adminService.existsCustomProperty(result)); - + // Check that property is available as a custom property Map propDefs = adminService.getCustomPropertyDefinitions(ASPECT_RECORD); assertNotNull(propDefs); assertTrue(propDefs.containsKey(result)); - + // Check the property definition PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); + assertNotNull(propDef); assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription()); - assertEquals("Label2", propDef.getTitle()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label2", propDef.getTitle(dictionaryService)); } finally { // Store the created property for cleanup later createdCustomProperties.add(result); - } + } } }); - + // Add property to record (long version) doTestInTransaction(new Test() { @Override public QName run() throws Exception - { + { return adminService.addCustomPropertyDefinition( - null, - ASPECT_RECORD, - "Label3", - DataTypeDefinition.TEXT, - "Title", - "Description", - "default", - false, - false, - false, + null, + ASPECT_RECORD, + "Label3", + DataTypeDefinition.TEXT, + "Title", + "Description", + "default", + false, + false, + false, null); } - + @Override - public void test(QName result) throws Exception + public void test(QName result) throws Exception { try - { + { // Check the property QName is correct assertNotNull(result); - assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); + assertEquals(RecordsManagementCustomModel.RM_CUSTOM_URI, result.getNamespaceURI()); assertTrue(adminService.existsCustomProperty(result)); - + // Check that property is available as a custom property Map propDefs = adminService.getCustomPropertyDefinitions(ASPECT_RECORD); assertNotNull(propDefs); //assertEquals(3, propDefs.size()); assertTrue(propDefs.containsKey(result)); - + // Check the property definition PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); + assertNotNull(propDef); assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription()); - assertEquals("Label3", propDef.getTitle()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label3", propDef.getTitle(dictionaryService)); assertEquals("default", propDef.getDefaultValue()); assertFalse(propDef.isMandatory()); assertFalse(propDef.isMultiValued()); assertFalse(propDef.isProtected()); - + } finally { // Store the created property for cleanup later createdCustomProperties.add(result); - } + } } }); - + // Failure: Add a property with the same name twice doTestInTransaction(new FailureTest ( @@ -337,15 +337,15 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase public void run() throws Exception { adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), - ASPECT_RECORD, - "Label1", - DataTypeDefinition.TEXT, - "Title", + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myRecordProp1"), + ASPECT_RECORD, + "Label1", + DataTypeDefinition.TEXT, + "Title", "Description"); } - }); - + }); + // Failure: Try and add a property to a type that isn't customisable doTestInTransaction(new FailureTest ( @@ -357,16 +357,16 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase public void run() throws Exception { adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myContentProp"), - TYPE_CONTENT, - "Label1", - DataTypeDefinition.TEXT, - "Title", + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myContentProp"), + TYPE_CONTENT, + "Label1", + DataTypeDefinition.TEXT, + "Title", "Description"); } - }); + }); } - + /** * @see RecordsManagementAdminService#makeCustomisable(QName) */ @@ -382,41 +382,41 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase adminService.makeCustomisable(TYPE_CUSTOM_TYPE); madeCustomisable.add(TYPE_CUSTOM_TYPE); assertTrue(adminService.isCustomisable(TYPE_CUSTOM_TYPE)); - + // Add a custom property return adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), - TYPE_CUSTOM_TYPE, - "Label", - DataTypeDefinition.TEXT, - "Title", + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), + TYPE_CUSTOM_TYPE, + "Label", + DataTypeDefinition.TEXT, + "Title", "Description"); } - + @Override - public void test(QName result) throws Exception + public void test(QName result) throws Exception { // Check the property QName is correct assertNotNull(result); assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), result); assertTrue(adminService.existsCustomProperty(result)); - + // Check that property is available as a custom property Map propDefs = adminService.getCustomPropertyDefinitions(TYPE_CUSTOM_TYPE); assertNotNull(propDefs); assertEquals(1, propDefs.size()); assertTrue(propDefs.containsKey(result)); - + // Check the property definition PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); + assertNotNull(propDef); assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription()); - assertEquals("Label", propDef.getTitle()); - + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label", propDef.getTitle(dictionaryService)); + } }); - + doTestInTransaction(new Test() { @Override @@ -427,41 +427,41 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase adminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); madeCustomisable.add(ASPECT_CUSTOM_ASPECT); assertTrue(adminService.isCustomisable(ASPECT_CUSTOM_ASPECT)); - + // Add a custom property return adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), - ASPECT_CUSTOM_ASPECT, - "Label", - DataTypeDefinition.TEXT, - "Title", - "Description"); + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), + ASPECT_CUSTOM_ASPECT, + "Label", + DataTypeDefinition.TEXT, + "Title", + "Description"); } - + @Override - public void test(QName result) throws Exception + public void test(QName result) throws Exception { // Check the property QName is correct assertNotNull(result); assertEquals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), result); assertTrue(adminService.existsCustomProperty(result)); - + // Check that property is available as a custom property Map propDefs = adminService.getCustomPropertyDefinitions(ASPECT_CUSTOM_ASPECT); assertNotNull(propDefs); assertEquals(1, propDefs.size()); assertTrue(propDefs.containsKey(result)); - + // Check the property definition PropertyDefinition propDef = propDefs.get(result); - assertNotNull(propDef); + assertNotNull(propDef); assertEquals(DataTypeDefinition.TEXT, propDef.getDataType().getName()); - assertEquals("Description", propDef.getDescription()); - assertEquals("Label", propDef.getTitle()); + assertEquals("Description", propDef.getDescription(dictionaryService)); + assertEquals("Label", propDef.getTitle(dictionaryService)); } - }); + }); } - + public void testUseCustomProperty() throws Exception { // Create custom property on type and aspect @@ -470,29 +470,29 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase @Override public QName run() throws Exception { - adminService.makeCustomisable(TYPE_CUSTOM_TYPE); + adminService.makeCustomisable(TYPE_CUSTOM_TYPE); madeCustomisable.add(TYPE_CUSTOM_TYPE); adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), - TYPE_CUSTOM_TYPE, - "Label", - DataTypeDefinition.TEXT, - "Title", + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewProperty"), + TYPE_CUSTOM_TYPE, + "Label", + DataTypeDefinition.TEXT, + "Title", "Description"); - adminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); + adminService.makeCustomisable(ASPECT_CUSTOM_ASPECT); madeCustomisable.add(ASPECT_CUSTOM_ASPECT); adminService.addCustomPropertyDefinition( - QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), - ASPECT_CUSTOM_ASPECT, - "Label", - DataTypeDefinition.TEXT, - "Title", - "Description"); - + QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "myNewAspectProperty"), + ASPECT_CUSTOM_ASPECT, + "Label", + DataTypeDefinition.TEXT, + "Title", + "Description"); + return null; } }); - + // Create nodes using custom type and aspect doTestInTransaction(new Test() { @@ -500,36 +500,36 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase public QName run() throws Exception { NodeRef customInstance1 = nodeService.createNode( - folder, - ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance1"), + folder, + ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance1"), TYPE_CUSTOM_TYPE).getChildRef(); NodeRef customInstance2 = nodeService.createNode( - folder, - ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance2"), + folder, + ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "myCustomInstance2"), TYPE_CONTENT).getChildRef(); nodeService.addAspect(customInstance2, ASPECT_CUSTOM_ASPECT, null); - + // Assert that both instances have the custom aspects applied assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties"))); assertTrue(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties"))); - + // Remove the custom aspect nodeService.removeAspect(customInstance2, ASPECT_CUSTOM_ASPECT); - + // Assert the custom property aspect is no longer applied applied assertTrue(nodeService.hasAspect(customInstance1, QName.createQName(RM_CUSTOM_URI, "rmtcustomTypeCustomProperties"))); assertFalse(nodeService.hasAspect(customInstance2, QName.createQName(RM_CUSTOM_URI, "rmtcustomAspectCustomProperties"))); - + return null; } - }, AuthenticationUtil.getSystemUserName()); + }, AuthenticationUtil.getSystemUserName()); } - - + + public void testCreateAndUseCustomChildReference() throws Exception - { + { long now = System.currentTimeMillis(); createAndUseCustomReference(CustomReferenceType.PARENT_CHILD, null, "superseded" + now, "superseding" + now); } @@ -539,7 +539,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase long now = System.currentTimeMillis(); createAndUseCustomReference(CustomReferenceType.BIDIRECTIONAL, "supporting" + now, null, null); } - + private void createAndUseCustomReference(final CustomReferenceType refType, final String label, final String source, final String target) throws Exception { final NodeRef testRecord1 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -548,16 +548,16 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { NodeRef result = utils.createRecord(rmFolder, "testRecordA" + System.currentTimeMillis()); return result; - } - }); + } + }); final NodeRef testRecord2 = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public NodeRef execute() throws Throwable { NodeRef result = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis()); return result; - } - }); + } + }); final QName generatedQName = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -586,11 +586,11 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase } System.out.println("Creating new " + refType + " reference definition: " + qNameResult); System.out.println(" params- label: '" + label + "' source: '" + source + "' target: '" + target + "'"); - + return qNameResult; - } - }); - + } + }); + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -601,11 +601,11 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase assertNotNull("Custom reference definition from adminService was null.", retrievedRefDefn); assertEquals(generatedQName, retrievedRefDefn.getName()); assertEquals(refType.equals(CustomReferenceType.PARENT_CHILD), retrievedRefDefn.isChild()); - + // Now we need to use the custom reference. // So we apply the aspect containing it to our test records. nodeService.addAspect(testRecord1, ASPECT_CUSTOM_ASSOCIATIONS, null); - + QName assocsAspectQName = QName.createQName("rmc:customAssocs", namespaceService); nodeService.addAspect(testRecord1, assocsAspectQName, null); @@ -618,9 +618,9 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase nodeService.createAssociation(testRecord1, testRecord2, generatedQName); } return null; - } - }); - + } + }); + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -628,7 +628,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase // Read back the reference value to make sure it was correctly applied. List childAssocs = nodeService.getChildAssocs(testRecord1); List retrievedAssocs = nodeService.getTargetAssocs(testRecord1, RegexQNamePattern.MATCH_ALL); - + Object newlyAddedRef = null; if (CustomReferenceType.PARENT_CHILD.equals(refType)) { @@ -647,7 +647,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase } } assertNotNull("newlyAddedRef was null.", newlyAddedRef); - + // Check that the reference has appeared in the data dictionary AspectDefinition customAssocsAspect = dictionaryService.getAspect(ASPECT_CUSTOM_ASSOCIATIONS); assertNotNull(customAssocsAspect); @@ -662,10 +662,10 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase customAssocsAspect.getAssociations().get(generatedQName)); } return null; - } - }); + } + }); } - + public void testGetAllProperties() { retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -678,17 +678,17 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase for (QName prop : props.keySet()) { System.out.println(" - " + prop.toString()); - - String propId = props.get(prop).getTitle(); + + String propId = props.get(prop).getTitle(dictionaryService); assertNotNull("null client-id for " + prop, propId); - + System.out.println(" " + propId); - } + } return null; - } - }); + } + }); } - + public void testGetAllReferences() { retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -701,15 +701,15 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase for (QName reference : references.keySet()) { System.out.println(" - " + reference.toString()); - System.out.println(" " + references.get(reference).getTitle()); + System.out.println(" " + references.get(reference).getTitle(dictionaryService)); } return null; - } - }); + } + }); } - + public void testGetAllConstraints() - { + { retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -720,18 +720,18 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase for (ConstraintDefinition constraint : constraints) { System.out.println(" - " + constraint.getName()); - System.out.println(" " + constraint.getTitle()); + System.out.println(" " + constraint.getTitle(dictionaryService)); } return null; - } - }); + } + }); } - + private boolean beforeMarker = false; private boolean onMarker = false; @SuppressWarnings("unused") private boolean inTest = false; - + public void testCreateReference() throws Exception { inTest = true; @@ -746,44 +746,44 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase NodeRef rec2 = utils.createRecord(rmFolder, "testRecordB" + System.currentTimeMillis()); Pair result = new Pair(rec1, rec2); return result; - } + } }); final NodeRef testRecord1 = testRecords.getFirst(); final NodeRef testRecord2 = testRecords.getSecond(); - + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable { utils.declareRecord(testRecord1); utils.declareRecord(testRecord2); - + policyComponent.bindClassBehaviour( - RecordsManagementPolicies.BEFORE_CREATE_REFERENCE, - this, + RecordsManagementPolicies.BEFORE_CREATE_REFERENCE, + this, new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "beforeCreateReference", NotificationFrequency.EVERY_EVENT)); policyComponent.bindClassBehaviour( - RecordsManagementPolicies.ON_CREATE_REFERENCE, - this, + RecordsManagementPolicies.ON_CREATE_REFERENCE, + this, new JavaBehaviour(RecordsManagementAdminServiceImplTest.this, "onCreateReference", NotificationFrequency.EVERY_EVENT)); - + assertFalse(beforeMarker); assertFalse(onMarker); - + adminService.addCustomReference(testRecord1, testRecord2, CUSTOM_REF_VERSIONS); - + assertTrue(beforeMarker); assertTrue(onMarker); return null; - } - }); + } + }); } finally { inTest = false; } - } - + } + public void beforeCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference) { beforeMarker = true; @@ -793,7 +793,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { onMarker = true; } - + public void testCreateCustomConstraints() throws Exception { final int beforeCnt = @@ -804,65 +804,65 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase List result = adminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); assertNotNull(result); return result.size(); - } - }); + } + }); final String conTitle = "test title - "+testRunID; final List allowedValues = new ArrayList(3); allowedValues.add("RED"); allowedValues.add("AMBER"); allowedValues.add("GREEN"); - + final QName testCon = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public QName execute() throws Throwable { String conLocalName = "test-"+testRunID; - + final QName result = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, conLocalName); - + adminService.addCustomConstraintDefinition(result, conTitle, true, allowedValues, MatchLogic.AND); return result; - } - }); - - + } + }); + + // Set the current security context as System - to see allowed values (unless caveat config is also updated for admin) AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable { List customConstraintDefs = adminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); assertEquals(beforeCnt+1, customConstraintDefs.size()); - + boolean found = false; for (ConstraintDefinition conDef : customConstraintDefs) { if (conDef.getName().equals(testCon)) { - assertEquals(conTitle, conDef.getTitle()); - + assertEquals(conTitle, conDef.getTitle(dictionaryService)); + Constraint con = conDef.getConstraint(); assertTrue(con instanceof RMListOfValuesConstraint); - + assertEquals("LIST", ((RMListOfValuesConstraint)con).getType()); assertEquals(3, ((RMListOfValuesConstraint)con).getAllowedValues().size()); - + found = true; break; } } assertTrue(found); return null; - } - }); + } + }); + - // Set the current security context as admin AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -870,55 +870,55 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase allowedValues.clear(); allowedValues.add("RED"); allowedValues.add("YELLOW"); - + adminService.changeCustomConstraintValues(testCon, allowedValues); return null; - } - }); - + } + }); + // Set the current security context as System - to see allowed values (unless caveat config is also updated for admin) AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); - + retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable { List customConstraintDefs = adminService.getCustomConstraintDefinitions(RecordsManagementCustomModel.RM_CUSTOM_MODEL); assertEquals(beforeCnt+1, customConstraintDefs.size()); - + boolean found = false; for (ConstraintDefinition conDef : customConstraintDefs) { if (conDef.getName().equals(testCon)) { - assertEquals(conTitle, conDef.getTitle()); - + assertEquals(conTitle, conDef.getTitle(dictionaryService)); + Constraint con = conDef.getConstraint(); assertTrue(con instanceof RMListOfValuesConstraint); - + assertEquals("LIST", ((RMListOfValuesConstraint)con).getType()); assertEquals(2, ((RMListOfValuesConstraint)con).getAllowedValues().size()); - + found = true; break; } } assertTrue(found); return null; - } - }); + } + }); + - // Set the current security context as admin AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); - + // Add custom property to record with test constraint retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable { String propLocalName = "myProp-"+testRunID; - + QName dataType = DataTypeDefinition.TEXT; String propTitle = "My property title"; String description = "My property description"; @@ -926,11 +926,11 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase boolean multiValued = false; boolean mandatory = false; boolean isProtected = false; - + QName propName = adminService.addCustomPropertyDefinition(null, ASPECT_RECORD, propLocalName, dataType, propTitle, description, defaultValue, multiValued, mandatory, isProtected, testCon); createdCustomProperties.add(propName); return null; - } - }); + } + }); } }