From 9260b6e8de9af9c1e0e56d3de2f28073eabb1558 Mon Sep 17 00:00:00 2001 From: David Ward Date: Mon, 11 Mar 2013 11:56:32 +0000 Subject: [PATCH 01/21] RM-626: Alfresco is not started with RM module applied - Fallout from ALF-16791 means we will have to code for API changes in 4.1.4 and introduce a new minimum Alfresco version - Fixes by Dmitry Vaserin git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@47857 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- gradle.properties | 2 +- .../module/org_alfresco_module_rm/module.properties | 2 +- .../org_alfresco_module_rm/rm-webscript-context.xml | 3 +++ .../RecordsManagementAdminServiceImpl.java | 4 ++-- .../action/impl/SplitEmailAction.java | 2 +- .../audit/RecordsManagementAuditServiceImpl.java | 4 ++-- .../email/RFC822MetadataExtracter.java | 2 +- .../forms/RecordsManagementFormFilter.java | 2 +- .../forms/RecordsManagementNodeFormFilter.java | 2 +- .../forms/RecordsManagementTypeFormFilter.java | 2 +- .../script/CustomReferenceDefinitionsGet.java | 9 ++++++++- .../script/CustomRefsGet.java | 13 +++++++++++-- .../script/CustomisableGet.java | 2 +- .../script/DispositionPropertiesGet.java | 9 ++++++++- .../script/ListOfValuesGet.java | 2 +- .../script/RecordMetaDataAspectsGet.java | 2 +- .../script/slingshot/RMSearchPropertiesGet.java | 4 ++-- 17 files changed, 46 insertions(+), 20 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5709f5a4ac..f5756a2a5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ groupid=alfresco packageName=rm version=2.0.2 build=dev -alfrescoBaseVersion=4.0.2 +alfrescoBaseVersion=4.1.4 diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties index face4e58d4..d9bc8ffb9f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties @@ -8,4 +8,4 @@ module.title=Records Management module.description=Alfresco Record Management Extension module.version=2.0.2 -module.repo.version.min=4.0.2 \ No newline at end of file +module.repo.version.min=4.1.4 \ 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 d9b8e146f3..2e94106163 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 @@ -52,6 +52,7 @@ + @@ -67,6 +68,7 @@ + @@ -115,6 +117,7 @@ + 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 e7c116d913..b61fc1da5b 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 @@ -421,7 +421,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin if (name.endsWith("Properties") == true) { QName type = null; - String prefixString = aspectDef.getDescription(); + String prefixString = aspectDef.getDescription(dictionaryService); if (prefixString == null) { // Backward compatibility from previous RM V1.0 custom models @@ -1183,7 +1183,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin { for (AssociationDefinition associationDefinition : getCustomReferenceDefinitions().values()) { - if (associationDefinition.getTitle().equalsIgnoreCase(label)) + if (associationDefinition.getTitle(dictionaryService).equalsIgnoreCase(label)) { return true; } 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 9523e21558..9df7143f61 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 @@ -84,7 +84,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase 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; 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 ed279bd596..bc590d3df8 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 @@ -822,7 +822,7 @@ public class RecordsManagementAuditServiceImpl if (nodeTypeQname != null) { TypeDefinition typeDef = dictionaryService.getType(nodeTypeQname); - nodeType = (typeDef != null) ? typeDef.getTitle() : null; + nodeType = (typeDef != null) ? typeDef.getTitle(dictionaryService) : null; } } else if (values.containsKey(RecordsManagementAuditService.RM_AUDIT_DATA_LOGIN_USERNAME)) @@ -1300,7 +1300,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..06a1fc857a 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 @@ -39,7 +39,7 @@ import org.alfresco.service.namespace.QName; 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; 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 7b6579f5d8..267a0a5f5a 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 @@ -130,7 +130,7 @@ public abstract class RecordsManagementFormFilter extends AbstractFilt 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, rmServiceRegistry.getDictionaryService()); form.addField(field); 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 420c6eccec..ee0a7336b5 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 @@ -198,7 +198,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter 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()) 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 28aa892093..9bbb7a374f 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 @@ -132,7 +132,7 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter // 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, rmServiceRegistry.getDictionaryService()); form.addFields(fields); } } 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 208102feba..612ae3a7f3 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.NamespaceService; import org.alfresco.service.namespace.QName; import org.springframework.extensions.webscripts.Cache; @@ -56,6 +57,7 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript private RecordsManagementAdminService rmAdminService; private NamespaceService namespaceService; + private DictionaryService dictionaryService; public void setNamespaceService(NamespaceService namespaceService) { @@ -67,6 +69,11 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript this.rmAdminService = rmAdminService; } + public void setDictionaryService(DictionaryService dictionaryService) + { + this.dictionaryService = dictionaryService; + } + @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { @@ -120,7 +127,7 @@ public class CustomReferenceDefinitionsGet extends DeclarativeWebScript 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) 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..6db2f98b0f 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; @@ -59,12 +60,20 @@ public class CustomRefsGet extends AbstractRmWebScript 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) { @@ -132,7 +141,7 @@ public class CustomRefsGet extends AbstractRmWebScript if (assDef != null) { - String compoundTitle = assDef.getTitle(); + String compoundTitle = assDef.getTitle(dictionaryService); data.put(REF_ID, typeQName.getLocalName()); @@ -166,7 +175,7 @@ public class CustomRefsGet extends AbstractRmWebScript 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()); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java index ea9d52b5a8..0bef9f37a7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomisableGet.java @@ -96,7 +96,7 @@ public class CustomisableGet extends DeclarativeWebScript if (definition != null) { String name = qname.toPrefixString(namespaceService); - String title = definition.getTitle(); + String title = definition.getTitle(dictionaryService); if (title == null || title.length() == 0) { title = qname.getLocalName(); 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..d36466f82d 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,6 +43,7 @@ public class DispositionPropertiesGet extends DeclarativeWebScript { protected DispositionService dispositionService; protected NamespaceService namespaceService; + protected DictionaryService dictionaryService; /** * Sets the disposition service @@ -63,6 +65,11 @@ public class DispositionPropertiesGet extends DeclarativeWebScript this.namespaceService = namespaceService; } + 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) */ @@ -87,7 +94,7 @@ public class DispositionPropertiesGet extends DeclarativeWebScript 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()); 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..16de183d4f 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 @@ -259,7 +259,7 @@ public class ListOfValuesGet extends DeclarativeWebScript 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()); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RecordMetaDataAspectsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RecordMetaDataAspectsGet.java index a15ac40173..5b75e3898c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RecordMetaDataAspectsGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/RecordMetaDataAspectsGet.java @@ -91,7 +91,7 @@ public class RecordMetaDataAspectsGet extends DeclarativeWebScript if (aspectDefinition != null) { // Fet the label from the aspect definition - label = aspectDefinition.getTitle(); + label = aspectDefinition.getTitle(dictionaryService); } aspect.put("value", label); 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 8948cb0895..b8c677dcba 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 @@ -95,7 +95,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript } AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect); - Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(), propObjs); + Group group = new Group(aspect.getLocalName(), aspectDefinition.getTitle(dictionaryService), propObjs); groups.add(group); } @@ -157,7 +157,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript 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(); } From fe12afa57e50d2590c6a418c4babb2143a672005 Mon Sep 17 00:00:00 2001 From: Samuel Langlois Date: Mon, 11 Mar 2013 16:55:43 +0000 Subject: [PATCH 02/21] add the internal-staging Maven repo, to be able to get the yet unreleased 4.1.4 + remove transitivity to Alfresco dependencies git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@47883 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- build.gradle | 8 ++++++++ rm-server/build.gradle | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 01d9bc5aac..ca38580ce5 100644 --- a/build.gradle +++ b/build.gradle @@ -98,6 +98,14 @@ subprojects { password 'b@mb00' } } + // Temporarily add the internal-staging Maven repo, to be able to get the yet unreleased 4.1.4 + maven { + url "https://artifacts.alfresco.com/nexus/content/repositories/internal-staging" + credentials { + username 'bamboo' + password 'b@mb00' + } + } } dependencies { diff --git a/rm-server/build.gradle b/rm-server/build.gradle index 497848cc37..cb6ca069cd 100644 --- a/rm-server/build.gradle +++ b/rm-server/build.gradle @@ -12,8 +12,8 @@ dependencies { testRuntime files(configDir) testRuntime files(testResourceDir) - testRuntime group: 'org.alfresco.enterprise', name: 'alfresco', version: alfrescoBaseVersion, type: 'war' - testRuntime group: 'org.alfresco.enterprise', name: 'alfresco-solr', version: alfrescoBaseVersion, type: 'zip' + testRuntime group: 'org.alfresco.enterprise', name: 'alfresco', version: alfrescoBaseVersion, type: 'war', transitive: false + testRuntime group: 'org.alfresco.enterprise', name: 'alfresco-solr', version: alfrescoBaseVersion, type: 'zip', transitive: false } task fetchSOLR(type:Copy) { From e3ba4546b08d3012bede8a846bb4e8958c62fbc9 Mon Sep 17 00:00:00 2001 From: David Ward Date: Mon, 11 Mar 2013 17:40:28 +0000 Subject: [PATCH 03/21] RM-626: Unit test fallout git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@47891 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- ...RecordsManagementAdminServiceImplTest.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) 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 eb03a63656..31fd56ff56 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 @@ -214,8 +214,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase PropertyDefinition propDef = propDefs.get(result); 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 { @@ -259,8 +259,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase PropertyDefinition propDef = propDefs.get(result); 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 { @@ -310,8 +310,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase PropertyDefinition propDef = propDefs.get(result); 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()); @@ -411,8 +411,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase PropertyDefinition propDef = propDefs.get(result); 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)); } }); @@ -456,8 +456,8 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase PropertyDefinition propDef = propDefs.get(result); 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)); } }); } @@ -679,7 +679,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { 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); @@ -701,7 +701,7 @@ 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; } @@ -720,7 +720,7 @@ 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; } @@ -842,7 +842,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { if (conDef.getName().equals(testCon)) { - assertEquals(conTitle, conDef.getTitle()); + assertEquals(conTitle, conDef.getTitle(dictionaryService)); Constraint con = conDef.getConstraint(); assertTrue(con instanceof RMListOfValuesConstraint); @@ -891,7 +891,7 @@ public class RecordsManagementAdminServiceImplTest extends BaseRMTestCase { if (conDef.getName().equals(testCon)) { - assertEquals(conTitle, conDef.getTitle()); + assertEquals(conTitle, conDef.getTitle(dictionaryService)); Constraint con = conDef.getConstraint(); assertTrue(con instanceof RMListOfValuesConstraint); From 92df6f655d7f166fcba26dd116dbace5d820478c Mon Sep 17 00:00:00 2001 From: David Ward Date: Sat, 16 Mar 2013 22:13:12 +0000 Subject: [PATCH 04/21] ALF-18377: SyntaxError displayed when we try to create category in File Plan - Because RM needs to know about new public methods git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@48212 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../security/rm-method-security.properties | 5 +++++ 1 file changed, 5 insertions(+) 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 b772166c4c..71d5666e38 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 @@ -68,12 +68,15 @@ rm.methodsecurity.org.alfresco.service.cmr.model.FileFolderService.copy=RM.Read. 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.exists=RM_ALLOW 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 @@ -200,6 +203,7 @@ rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.deleteSite=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.findSites=RM_ALLOW 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 rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteGroup=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.getSiteRoleGroup=RM_ALLOW @@ -209,6 +213,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 rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.removeMembership=RM_ALLOW rm.methodsecurity.org.alfresco.service.cmr.site.SiteService.setMembership=RM_ALLOW From 48383b497ef3b4acc3efd4f17bb89aaec534023d Mon Sep 17 00:00:00 2001 From: David Ward Date: Tue, 19 Mar 2013 08:43:10 +0000 Subject: [PATCH 05/21] Set module.repo.version.max=4.1.99 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@48317 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/module/org_alfresco_module_rm/module.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties index d9bc8ffb9f..ed5f7435ab 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/module.properties @@ -8,4 +8,5 @@ module.title=Records Management module.description=Alfresco Record Management Extension module.version=2.0.2 -module.repo.version.min=4.1.4 \ No newline at end of file +module.repo.version.min=4.1.4 +module.repo.version.max=4.1.99 \ No newline at end of file From ccf4f1cd5448b84a676984d5d661ea23cb6f4fd9 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 2 Apr 2013 22:21:56 +0000 Subject: [PATCH 06/21] RM-664 (Not possible to edit event without changing the name) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@48749 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-service-context.xml | 207 +++++++++--------- .../rm-webscript-context.xml | 147 +++++++------ .../event/RecordsManagementEventService.java | 56 +++-- .../RecordsManagementEventServiceImpl.java | 179 +++++++++------ .../script/admin/RMEventBase.java | 67 ++++++ .../script/admin/RmEventPut.java | 124 ++++++----- .../script/admin/RmEventsPost.java | 139 +++++++----- 7 files changed, 542 insertions(+), 377 deletions(-) create mode 100644 rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml index d4858561ef..06f21ffa6f 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml @@ -5,25 +5,25 @@ - - + + + class="org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSelectionStrategy" > - + - + + depends-on="org_alfresco_module_rm_dictionaryBootstrap" init-method="init"> - + org.alfresco.module.org_alfresco_module_rm.RecordsManagementService @@ -87,26 +87,26 @@ org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.createRecordCategory=RM.Write.0 org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.isRecordFolderDeclared=RM.Read.0 org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.isRecordFolderClosed=RM.Read.0 - org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.createRecordFolder=RM.Write.0 - org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.getRecords=RM.Read.0,AFTER_RM.FilterNode + org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.createRecordFolder=RM.Write.0 + org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.getRecords=RM.Read.0,AFTER_RM.FilterNode org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.getRecordMetaDataAspects=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.getRecordFolders=RM.Read.0,AFTER_RM.FilterNode + org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.getRecordFolders=RM.Read.0,AFTER_RM.FilterNode org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.isRecordDeclared=RM.Read.0 org.alfresco.module.org_alfresco_module_rm.RecordsManagementService.*=RM_DENY ]]> - + - - + + - + org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService @@ -146,25 +146,25 @@ - - + - - + + - + - + org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService @@ -206,32 +206,32 @@ - + - - + + - + org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService @@ -277,12 +277,12 @@ - + - - + + - + @@ -297,7 +297,7 @@ { "records" : true, "vitalrecords" : true - } + } }, { "name" : "Undeclared Records", @@ -305,7 +305,7 @@ "search" : "ISNODE:T AND NOT ASPECT:\"rma:declaredRecord\"", "searchparams" : { - "records" : true, + "records" : true, "recordfolders" : false, "undeclaredrecords" : true } @@ -357,9 +357,9 @@ ] ]]> - + - + org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService @@ -404,29 +404,29 @@ org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.getSavedSearches=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.getSavedSearch=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.saveSearch=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.deleteSavedSearch=RM_ALLOW - org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.addReports=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.deleteSavedSearch=RM_ALLOW + org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.addReports=RM_ALLOW org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService.*=RM_DENY ]]> - + - - + + - + - + org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService @@ -466,11 +466,11 @@ - - + - - + + - + org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService @@ -520,7 +520,7 @@ - + @@ -533,7 +533,7 @@ - - + - + - + org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService @@ -584,7 +584,7 @@ - + @@ -597,7 +597,7 @@ - - + - + @@ -627,11 +628,11 @@ rma:recordCategory rma:recordFolder rma:record - rma:nonElectronicDocument + rma:nonElectronicDocument - + org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService @@ -659,7 +660,7 @@ - + @@ -672,7 +673,7 @@ - - + - + - + - + @@ -731,7 +732,7 @@ - + org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService @@ -758,7 +759,7 @@ - + @@ -771,7 +772,7 @@ - - + - - @@ -800,10 +801,10 @@ - + - - + + @@ -814,7 +815,7 @@ - + @@ -827,7 +828,7 @@ - - + @@ -855,10 +856,10 @@ - + - - + + @@ -869,17 +870,17 @@ - - + + - + - + @@ -888,12 +889,12 @@ - + - + - + @@ -901,7 +902,7 @@ - + @@ -909,11 +910,11 @@ - + - + @@ -926,8 +927,8 @@ - - + @@ -958,7 +959,7 @@ - + @@ -976,7 +977,7 @@ - + @@ -989,5 +990,5 @@ - - \ No newline at end of file + + \ 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 2e94106163..30e2dba468 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 @@ -7,7 +7,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -29,25 +29,25 @@ - + - + - + - + @@ -64,7 +64,7 @@ - + @@ -84,24 +84,24 @@ - + - + - + - + - + @@ -112,21 +112,21 @@ - + - + - + @@ -135,11 +135,11 @@ - + - + @@ -148,17 +148,17 @@ - + - + - + @@ -167,7 +167,7 @@ - + @@ -176,7 +176,7 @@ - + @@ -185,18 +185,18 @@ - + - + - + @@ -204,91 +204,94 @@ - + - + - + - - + + - + - + - + - - - + - + + + + - + - - + + - - + + - - + + - + - + - + - + - + - + @@ -297,7 +300,7 @@ - + @@ -312,7 +315,7 @@ - + @@ -325,32 +328,32 @@ - + - - - - - - - @@ -361,22 +364,22 @@ - - - - - + \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java index a32ff9f879..b8252ea8bb 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java @@ -22,79 +22,89 @@ import java.util.List; /** * Records management event service interface - * + * * @author Roy Wetherall */ public interface RecordsManagementEventService { /** * Register an event type - * + * * @param eventType event type */ void registerEventType(RecordsManagementEventType eventType); - + /** * Get a list of the event types - * + * * @return List list of the event types */ List getEventTypes(); - + /** * Get the records management event type - * + * * @param eventType name - * @return RecordsManagementEventType event type + * @return RecordsManagementEventType event type */ RecordsManagementEventType getEventType(String eventTypeName); - + /** * Get the list of available events - * + * * @return List list of events */ List getEvents(); - + /** * Get a records management event given its name. Returns null if the event name is not * recognised. - * + * * @param eventName event name * @return RecordsManagementEvent event */ RecordsManagementEvent getEvent(String eventName); - + /** * Indicates whether a perticular event exists. Returns true if it does, false otherwise. - * + * * @param eventName event name * @return boolean true if event exists, false otherwise */ boolean existsEvent(String eventName); - + /** - * Indicates whether a particular event display label exists. Returns true if it does, false otherwise. - * + * Indicates whether a particular event can be created. Returns true if it is possible, false otherwise. + * * @param eventDisplayLabel event display label - * @return true if event display label exists, false otherwise + * @param eventName event name + * @return true if the event can be created, false otherwise */ - boolean existsEventDisplayLabel(String eventDisplayLabel); - + boolean canCreateEvent(String eventDisplayLabel, String eventName); + + /** + * Indicates whether a particular event can be edited. Returns true if it is possible, false otherwise. + * + * @param eventDisplayLabel event display label + * @param eventName event name + * @return true if the event can be edited, false otherwise + */ + boolean canEditEvent(String eventDisplayLabel, String eventName); + /** * Add an event - * + * * @param eventType event type * @param eventName event name * @param eventDisplayLabel event display label */ RecordsManagementEvent addEvent(String eventType, String eventName, String eventDisplayLabel); - + /** * Remove an event - * + * * @param eventName event name */ - void removeEvent(String eventName); + void removeEvent(String eventName); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java index bc83fe244b..1e5ce1753e 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java @@ -33,12 +33,13 @@ import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.util.ParameterCheck; import org.json.JSONArray; import org.json.JSONObject; /** * Records management event service implementation - * + * * @author Roy Wetherall */ public class RecordsManagementEventServiceImpl implements RecordsManagementEventService @@ -46,32 +47,32 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent /** Reference to the rm event config node */ private static final StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); private static final NodeRef CONFIG_NODE_REF = new NodeRef(SPACES_STORE, "rm_event_config"); - + /** Node service */ private NodeService nodeService; - + /** Content service */ private ContentService contentService; - + /** Registered event types */ private Map eventTypes = new HashMap(7); - + /** Available events */ private Map events; - + /** * Set the node service - * + * * @param nodeService node service */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } - + /** * Set the content service - * + * * @param contentService content service */ public void setContentService(ContentService contentService) @@ -94,7 +95,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent { return new ArrayList(this.eventTypes.values()); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEvents() */ @@ -102,11 +103,11 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent { return new ArrayList(this.getEventMap().values()); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#getEvent(java.lang.String) */ - public RecordsManagementEvent getEvent(String eventName) + public RecordsManagementEvent getEvent(String eventName) { if (getEventMap().containsKey(eventName) == false) { @@ -114,7 +115,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent } return getEventMap().get(eventName); } - + /** * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#existsEvent(java.lang.String) */ @@ -122,24 +123,76 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent { return getEventMap().containsKey(eventName); } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#existsEventDisplayLabel(java.lang.String) - */ - @SuppressWarnings("rawtypes") - public boolean existsEventDisplayLabel(String eventDisplayLabel) - { - for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();) - { - RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next(); - if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel)) - { - return true; - } - } - return false; - } - + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canCreateEvent(java.lang.String, java.lang.String) + */ + @SuppressWarnings("rawtypes") + public boolean canCreateEvent(String eventDisplayLabel, String eventName) + { + ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel); + ParameterCheck.mandatoryString("eventName", eventName); + + boolean canCreateEvent = true; + + if (existsEvent(eventName) == true) + { + canCreateEvent = false; + } + + if (canCreateEvent == true) + { + for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();) + { + RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next(); + if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel)) + { + canCreateEvent = false; + break; + } + } + } + + return canCreateEvent; + } + + /** + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canEditEvent(java.lang.String, java.lang.String) + */ + @SuppressWarnings("rawtypes") + public boolean canEditEvent(String eventDisplayLabel, String eventName) + { + ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel); + ParameterCheck.mandatoryString("eventName", eventName); + + boolean canEditEvent = true; + + if (existsEvent(eventName) == false) + { + throw new AlfrescoRuntimeException("The event '" + eventName + "' does not exist."); + } + + for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();) + { + RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next(); + if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel)) + { + if (recordsManagementEvent.getName().equalsIgnoreCase(eventName)) + { + canEditEvent = false; + } + else + { + throw new AlfrescoRuntimeException("Cannot edit event. An event with the display label '" + + eventDisplayLabel + "' already exist."); + } + break; + } + } + + return canEditEvent; + } + /** * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#addEvent(java.lang.String, java.lang.String, java.lang.String) */ @@ -149,19 +202,19 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent if (eventTypes.containsKey(eventType) == false) { throw new AlfrescoRuntimeException( - "Can not add event because event " + - eventName + - " has an undefined eventType. (" + "Can not add event because event " + + eventName + + " has an undefined eventType. (" + eventType + ")"); } - + // Create event and add to map RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel); getEventMap().put(event.getName(), event); - + // Persist the changes to the event list saveEvents(); - + return new RecordsManagementEvent(eventType, eventName, eventDisplayLabel); } @@ -172,14 +225,14 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent { // Remove the event from the map getEventMap().remove(eventName); - + // Persist the changes to the event list saveEvents(); - } - + } + /** * Helper method to get the event map. Loads initial instance from persisted configuration file. - * + * * @return Map map of available events by event name */ private Map getEventMap() @@ -190,7 +243,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent } return this.events; } - + /** * Load the events from the persistant storage */ @@ -205,46 +258,46 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent { throw new AlfrescoRuntimeException("Unable to find records management event configuration node."); } - + // Read content from config node ContentReader reader = contentService.getReader(CONFIG_NODE_REF, ContentModel.PROP_CONTENT); String jsonString = reader.getContentString(); - + JSONObject configJSON = new JSONObject(jsonString); JSONArray eventsJSON = configJSON.getJSONArray("events"); - + events = new HashMap(eventsJSON.length()); - + for (int i = 0; i < eventsJSON.length(); i++) { // Get the JSON object that represents the event JSONObject eventJSON = eventsJSON.getJSONObject(i); - + // Get the details of the event String eventType = eventJSON.getString("eventType"); String eventName = eventJSON.getString("eventName"); String eventDisplayLabel = eventJSON.getString("eventDisplayLabel"); - + // Check that the eventType is valid if (eventTypes.containsKey(eventType) == false) { throw new AlfrescoRuntimeException( - "Can not load rm event configuration because event " + - eventName + - " has an undefined eventType. (" + "Can not load rm event configuration because event " + + eventName + + " has an undefined eventType. (" + eventType + ")"); } - + // Create event and add to map RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel); - events.put(event.getName(), event); + events.put(event.getName(), event); } return null; } - + }, AuthenticationUtil.getSystemUserName()); } - + /** * Save the events to the peristant storage */ @@ -259,10 +312,10 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent { throw new AlfrescoRuntimeException("Unable to find records management event configuration node."); } - - JSONObject configJSON = new JSONObject(); + + JSONObject configJSON = new JSONObject(); JSONArray eventsJSON = new JSONArray(); - + int index = 0; for (RecordsManagementEvent event : events.values()) { @@ -270,19 +323,19 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent eventJSON.put("eventType", event.getType()); eventJSON.put("eventName", event.getName()); eventJSON.put("eventDisplayLabel", event.getDisplayLabel()); - + eventsJSON.put(index, eventJSON); index++; - } + } configJSON.put("events", eventsJSON); - + // Get content writer ContentWriter contentWriter = contentService.getWriter(CONFIG_NODE_REF, ContentModel.PROP_CONTENT, true); contentWriter.putContent(configJSON.toString()); - + return null; } - + }, AuthenticationUtil.getSystemUserName()); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java new file mode 100644 index 0000000000..7483eb7ef9 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RMEventBase.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2005-2013 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.script.admin; + +import org.apache.commons.lang.StringUtils; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; + +/** + * Base class for Records management event web scripts + * + * @author Tuna Aksoy + * @since 2.1 + */ +public class RMEventBase extends DeclarativeWebScript +{ + /** + * Helper method for getting the value for a key from a JSON object + * + * @param json The request content as JSON object + * @param key The key for which the value should be retrieved (e.g. "eventName") + * @return String The value for the provided key if the key exists, null otherwise + * @throws JSONException If there is no string value for the key + */ + protected String getValue(JSONObject json, String key) throws JSONException + { + String result = null; + if (json.has(key) == true) + { + result = json.getString(key); + } + return result; + } + + /** + * Helper method for checking the key (e.g. "eventName") + * + * @param key String The key which will be checked + * @param msg String The error message to throw if the key doesn't have a value + */ + protected void doCheck(String key, String msg) + { + if (StringUtils.isBlank(key)) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, msg); + } + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java index 1af46bd6e6..4b44a852f6 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java @@ -22,35 +22,31 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.alfresco.util.ParameterCheck; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** * Records management event PUT web script - * + * * @author Roy Wetherall */ -public class RmEventPut extends DeclarativeWebScript +public class RmEventPut extends RMEventBase { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmEventPut.class); - - /** Reccords management event service */ + /** Records management event service */ private RecordsManagementEventService rmEventService; - + /** * Set the records management event service - * + * * @param rmEventService */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) @@ -58,59 +54,49 @@ public class RmEventPut extends DeclarativeWebScript this.rmEventService = rmEventService; } + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { - Map model = new HashMap(); + ParameterCheck.mandatory("req", req); + + Map model = new HashMap(); JSONObject json = null; try { - // Event name - Map templateVars = req.getServiceMatch().getTemplateVars(); - String eventName = templateVars.get("eventname"); - if (eventName == null) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided on the URL."); - } - - // Check the event exists - if (rmEventService.existsEvent(eventName) == false) - { - throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist."); - } - + // Convert the request content to JSON json = new JSONObject(new JSONTokener(req.getContent().getContent())); - - String eventDisplayLabel = null; - if (json.has("eventDisplayLabel") == true) + + // Check the event name + String eventName = getValue(json, "eventName"); + doCheck(eventName, "No event name was provided."); + + // Check the event display label + String eventDisplayLabel = getValue(json, "eventDisplayLabel"); + doCheck(eventDisplayLabel, "No event display label was provided."); + + // Check if the event can be edited or not + RecordsManagementEvent event = null; + if (canEditEvent(eventDisplayLabel, eventName) == true) { - eventDisplayLabel = json.getString("eventDisplayLabel"); + // Check the event type + String eventType = getValue(json, "eventType"); + doCheck(eventType, "No event type was provided."); + + // Create event + event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel); } - if (eventDisplayLabel == null || eventDisplayLabel.length() == 0) + else { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event display label provided."); + // Get event + event = rmEventService.getEvent(eventName); } - if (rmEventService.existsEventDisplayLabel(eventDisplayLabel)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Cannot edit event. The event display label '" - + eventDisplayLabel + "' already exists."); - } - - String eventType = null; - if (json.has("eventType") == true) - { - eventType = json.getString("eventType"); - } - if (eventType == null || eventType.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event type provided."); - } - - - RecordsManagementEvent event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel); + model.put("event", event); - } catch (IOException iox) { @@ -122,7 +108,31 @@ public class RmEventPut extends DeclarativeWebScript throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je); } - + return model; } + + /** + * Helper method for checking if an event can be edited or not. Throws an + * error if an event with the same display label already exists. + * + * @param eventDisplayLabel The display label of the event + * @param eventName The name of the event + * @return true if the event can be edited, false otherwise + */ + private boolean canEditEvent(String eventDisplayLabel, String eventName) + { + boolean canEditEvent; + + try + { + canEditEvent = rmEventService.canEditEvent(eventDisplayLabel, eventName); + } + catch (AlfrescoRuntimeException are) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, are.getLocalizedMessage()); + } + + return canEditEvent; + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java index 5384764881..4d5f7b2f0b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventsPost.java @@ -25,33 +25,29 @@ import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent; import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService; import org.alfresco.util.GUID; -import org.springframework.extensions.webscripts.Cache; -import org.springframework.extensions.webscripts.DeclarativeWebScript; -import org.springframework.extensions.webscripts.Status; -import org.springframework.extensions.webscripts.WebScriptException; -import org.springframework.extensions.webscripts.WebScriptRequest; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.alfresco.util.ParameterCheck; +import org.apache.commons.lang.StringUtils; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptException; +import org.springframework.extensions.webscripts.WebScriptRequest; /** - * - * + * Records management event POST web script + * * @author Roy Wetherall */ -public class RmEventsPost extends DeclarativeWebScript +public class RmEventsPost extends RMEventBase { - @SuppressWarnings("unused") - private static Log logger = LogFactory.getLog(RmEventsPost.class); - - /** Reccords management event service */ + /** Records management event service */ private RecordsManagementEventService rmEventService; - + /** * Set the records management event service - * + * * @param rmEventService */ public void setRecordsManagementEventService(RecordsManagementEventService rmEventService) @@ -59,57 +55,41 @@ public class RmEventsPost extends DeclarativeWebScript this.rmEventService = rmEventService; } - + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ @Override public Map executeImpl(WebScriptRequest req, Status status, Cache cache) { - Map model = new HashMap(); + ParameterCheck.mandatory("req", req); + + Map model = new HashMap(); JSONObject json = null; try { + // Convert the request content to JSON json = new JSONObject(new JSONTokener(req.getContent().getContent())); - - String eventName = null; - if (json.has("eventName") == true) - { - eventName = json.getString("eventName"); - } - - if (eventName == null || eventName.length() == 0) - { - // Generate the event name - eventName = GUID.generate(); - } - - String eventDisplayLabel = null; - if (json.has("eventDisplayLabel") == true) - { - eventDisplayLabel = json.getString("eventDisplayLabel"); - } - if (eventDisplayLabel == null || eventDisplayLabel.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event display label provided."); - } - if (rmEventService.existsEventDisplayLabel(eventDisplayLabel)) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, - "Cannot create event. The event display label '" - + eventDisplayLabel + "' already exists."); - } - - String eventType = null; - if (json.has("eventType") == true) - { - eventType = json.getString("eventType"); - } - if (eventType == null || eventType.length() == 0) - { - throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No event type provided."); - } - + + // Get the event name + String eventName = getEventName(json); + + // Check the event display label + String eventDisplayLabel = getValue(json, "eventDisplayLabel"); + doCheck(eventDisplayLabel, "No event display label was provided."); + + // Check if the event can be created + canCreateEvent(eventDisplayLabel, eventName); + + // Check the event type + String eventType = getValue(json, "eventType"); + doCheck(eventType, "No event type was provided."); + + // Create event RecordsManagementEvent event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel); + model.put("event", event); - } catch (IOException iox) { @@ -121,7 +101,48 @@ public class RmEventsPost extends DeclarativeWebScript throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je); } - + return model; } + + /** + * Helper method for getting the event name + * + * @param json The request content as JSON object + * @return String The event name. A generated GUID if it doesn't exist + * @throws JSONException If there is no string value for the key + */ + private String getEventName(JSONObject json) throws JSONException + { + String eventName = getValue(json, "eventName"); + + if (StringUtils.isBlank(eventName)) + { + // Generate the event name + eventName = GUID.generate(); + } + + return eventName; + } + + /** + * Helper method for checking if an event can be created or not. Throws an + * error if the event already exists. + * + * @param eventDisplayLabel The display label of the event + * @param eventName The name of the event + */ + private boolean canCreateEvent(String eventDisplayLabel, String eventName) + { + boolean canCreateEvent = true; + + if (rmEventService.canCreateEvent(eventDisplayLabel, eventName) == false) + { + throw new WebScriptException(Status.STATUS_BAD_REQUEST, + "Cannot create event. An event with the display label '" + + eventDisplayLabel + "' already exists."); + } + + return canCreateEvent; + } } \ No newline at end of file From 8e9dc2deb05d011d9b09212c471120a3b52f6c8a Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 3 Apr 2013 12:48:45 +0000 Subject: [PATCH 07/21] RM-664 (Not possible to edit event without changing the name) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@48772 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../event/RecordsManagementEventService.java | 3 ++- .../RecordsManagementEventServiceImpl.java | 20 +++++++++++++------ .../script/admin/RmEventPut.java | 15 +++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java index b8252ea8bb..528491768f 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventService.java @@ -87,9 +87,10 @@ public interface RecordsManagementEventService * * @param eventDisplayLabel event display label * @param eventName event name + * @param eventType event type * @return true if the event can be edited, false otherwise */ - boolean canEditEvent(String eventDisplayLabel, String eventName); + boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType); /** * Add an event diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java index 1e5ce1753e..1724ec99bd 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/event/RecordsManagementEventServiceImpl.java @@ -145,7 +145,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();) { RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next(); - if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel)) + if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel) == true) { canCreateEvent = false; break; @@ -157,13 +157,14 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent } /** - * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canEditEvent(java.lang.String, java.lang.String) + * @see org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService#canEditEvent(java.lang.String, java.lang.String, java.lang.String) */ @SuppressWarnings("rawtypes") - public boolean canEditEvent(String eventDisplayLabel, String eventName) + public boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) { ParameterCheck.mandatoryString("eventDisplayLabel", eventDisplayLabel); ParameterCheck.mandatoryString("eventName", eventName); + ParameterCheck.mandatoryString("eventType", eventType); boolean canEditEvent = true; @@ -175,11 +176,18 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent for (Iterator iterator = getEventMap().values().iterator(); iterator.hasNext();) { RecordsManagementEvent recordsManagementEvent = (RecordsManagementEvent) iterator.next(); - if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel)) + if (recordsManagementEvent.getDisplayLabel().equalsIgnoreCase(eventDisplayLabel) == true) { - if (recordsManagementEvent.getName().equalsIgnoreCase(eventName)) + if (recordsManagementEvent.getName().equalsIgnoreCase(eventName) == true) { - canEditEvent = false; + if (recordsManagementEvent.getType().equalsIgnoreCase(eventType) == false) + { + canEditEvent = true; + } + else + { + canEditEvent = false; + } } else { diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java index 4b44a852f6..b45daaf7f1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/admin/RmEventPut.java @@ -79,14 +79,14 @@ public class RmEventPut extends RMEventBase String eventDisplayLabel = getValue(json, "eventDisplayLabel"); doCheck(eventDisplayLabel, "No event display label was provided."); + // Check the event type + String eventType = getValue(json, "eventType"); + doCheck(eventType, "No event type was provided."); + // Check if the event can be edited or not RecordsManagementEvent event = null; - if (canEditEvent(eventDisplayLabel, eventName) == true) + if (canEditEvent(eventDisplayLabel, eventName, eventType) == true) { - // Check the event type - String eventType = getValue(json, "eventType"); - doCheck(eventType, "No event type was provided."); - // Create event event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel); } @@ -118,15 +118,16 @@ public class RmEventPut extends RMEventBase * * @param eventDisplayLabel The display label of the event * @param eventName The name of the event + * @param eventType The type of the event * @return true if the event can be edited, false otherwise */ - private boolean canEditEvent(String eventDisplayLabel, String eventName) + private boolean canEditEvent(String eventDisplayLabel, String eventName, String eventType) { boolean canEditEvent; try { - canEditEvent = rmEventService.canEditEvent(eventDisplayLabel, eventName); + canEditEvent = rmEventService.canEditEvent(eventDisplayLabel, eventName, eventType); } catch (AlfrescoRuntimeException are) { From 70ba19991c7bb31903015a7af9fd4557687f7d49 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 12 Jun 2013 02:22:35 +0000 Subject: [PATCH 08/21] DOD Recert: Allow category and folder id to be editable upon creation. * generated id is shown by default and can be modified git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50932 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RecordsManagementTypeFormFilter.java | 60 ++++++------------- 1 file changed, 18 insertions(+), 42 deletions(-) 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 9bbb7a374f..56f3939301 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 @@ -26,6 +26,7 @@ import java.util.Set; import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.repo.forms.Field; +import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.FieldGroup; import org.alfresco.repo.forms.Form; import org.alfresco.repo.forms.FormData; @@ -84,8 +85,12 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter * java.util.List, java.util.List, org.alfresco.repo.forms.Form, * java.util.Map) */ - public void afterGenerate(TypeDefinition type, List fields, List forcedFields, Form form, - Map context) + public void afterGenerate( + TypeDefinition type, + List fields, + List forcedFields, + Form form, + Map context) { QName typeName = type.getName(); if (rmAdminService.isCustomisable(typeName) == true) @@ -103,8 +108,17 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter } } - // Group fields - // groupFields(form); + // set the id + List fieldDefs = form.getFieldDefinitions(); + for (FieldDefinition fieldDef : fieldDefs) + { + String prefixName = fieldDef.getName(); + if (prefixName.equals("rma:identifier")) + { + String defaultId = identifierService.generateIdentifier(typeName, null); + fieldDef.setDefaultValue(defaultId); + } + } } /** @@ -143,42 +157,4 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter public void afterPersist(TypeDefinition item, FormData data, final NodeRef nodeRef) { } - - /** - * Puts all fields in a group to workaround ALF-6089. - * - * @param form The form being generated - */ -// protected void groupFields(Form form) -// { -// // to control the order of the fields add the name, title and description fields to -// // a field group containing just that field, all other fields that are not already -// // in a group go into an "other" field group. The client config can then declare a -// // client side set with the same id and order them correctly. -// -// List fieldDefs = form.getFieldDefinitions(); -// for (FieldDefinition fieldDef : fieldDefs) -// { -// FieldGroup group = fieldDef.getGroup(); -// if (group == null) -// { -// if (fieldDef.getName().equals(ContentModel.PROP_NAME.toPrefixString(this.namespaceService))) -// { -// fieldDef.setGroup(NAME_FIELD_GROUP); -// } -// else if (fieldDef.getName().equals(ContentModel.PROP_TITLE.toPrefixString(this.namespaceService))) -// { -// fieldDef.setGroup(TITLE_FIELD_GROUP); -// } -// else if (fieldDef.getName().equals(ContentModel.PROP_DESCRIPTION.toPrefixString(this.namespaceService))) -// { -// fieldDef.setGroup(DESC_FIELD_GROUP); -// } -// else -// { -// fieldDef.setGroup(OTHER_FIELD_GROUP); -// } -// } -// } -// } } From cb6eb52bbf6e83cad370ce8218ed297149b58de3 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 12 Jun 2013 04:09:07 +0000 Subject: [PATCH 09/21] DOD Recert: Allow permissions to be set on the file plan node (so that Dan and Jan can create root categories) * Merge HEAD to DEV/DODCERT - r43798 RM-552 (Add 'Manage Permission' action to file plan toolbar) - r43859 RM-552 (Add 'Manage Permission' action to file plan toolbar) * Changed the icons - r43863 RM-552 (Add 'Manage Permission' action to file plan toolbar) * Changed the existing ManageAccessRights capability and reusing it git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50933 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-capabilities-group-context.xml | 3 +- .../rm-capabilities-context.xml | 23 +++++++------- .../rm-ui-evaluators-context.xml | 30 +++++++++---------- .../RecordsManagementSecurityServiceImpl.java | 9 ++++-- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml index 0312f6512b..407699cbff 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/capability/rm-capabilities-group-context.xml @@ -141,6 +141,5 @@ - - + \ No newline at end of file diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml index a636762d31..0f381d7dd9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml @@ -169,17 +169,18 @@ - - - - - - - - - - + + + + + + + + + + + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml index 2465f4804d..9bfae278a0 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-ui-evaluators-context.xml @@ -299,20 +299,20 @@ - - - - - - RECORD_CATEGORY - RECORD_FOLDER - RECORD - - - - - + + + + + + FILE_PLAN + RECORD_CATEGORY + RECORD_FOLDER + + + + + @@ -537,7 +537,7 @@ - + diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java index 9c0f85f4c6..d96b2b9330 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/security/RecordsManagementSecurityServiceImpl.java @@ -830,9 +830,12 @@ public class RecordsManagementSecurityServiceImpl implements RecordsManagementSe AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork() { public Boolean doWork() throws Exception - { - if (recordsManagementService.isFilePlan(nodeRef) == false && - recordsManagementService.isRecordCategory(nodeRef) == true) + { + if (recordsManagementService.isFilePlan(nodeRef) == true) + { + setPermissionDown(nodeRef, authority, permission); + } + else if (recordsManagementService.isRecordCategory(nodeRef) == true) { setReadPermissionUp(nodeRef, authority); setPermissionDown(nodeRef, authority, permission); From a33a8da404b4f6851996b010653078829ddf1eb4 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 12 Jun 2013 05:15:01 +0000 Subject: [PATCH 10/21] DOD Recert: Search sort order now works as expected git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50934 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RecordsManagementSearchParameters.java | 27 +++++++------------ .../RecordsManagementSearchServiceImpl.java | 4 +-- .../SavedSearchDetailsCompatibility.java | 16 ++++------- .../search/SortItem.java | 15 +++++++++++ 4 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SortItem.java diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java index 4529833148..a81f68b19c 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.json.JSONArray; @@ -38,14 +37,6 @@ import org.json.JSONObject; @SuppressWarnings("serial") public class RecordsManagementSearchParameters { - /** Default sort order */ - private static final Map DEFAULT_SORT_ORDER = new HashMap() - { - { - put(ContentModel.PROP_NAME, Boolean.TRUE); - } - }; - /** Default templates */ private static final Map DEFAULT_TEMPLATES = new HashMap() { @@ -87,7 +78,7 @@ public class RecordsManagementSearchParameters private boolean includeCutoff = false; private List includedContainerTypes = DEFAULT_INCLUDED_CONTAINER_TYPES; - private Map sortOrder = DEFAULT_SORT_ORDER; + private List sortOrder; private Map templates = DEFAULT_TEMPLATES; private static final String JSON_MAXITEMS = "maxitems"; @@ -196,16 +187,16 @@ public class RecordsManagementSearchParameters if (jsonObject.has(JSON_SORT) == true) { JSONArray jsonArray = jsonObject.getJSONArray(JSON_SORT); - Map sortOrder = new HashMap(jsonArray.length()); + List sortOrder = new ArrayList(jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { JSONObject sortJSONObject = jsonArray.getJSONObject(i); if (sortJSONObject.has(JSON_FIELD) == true && sortJSONObject.has(JSON_ASCENDING) == true) { - sortOrder.put( + sortOrder.add(new SortItem( QName.createQName(sortJSONObject.getString(JSON_FIELD), namespaceService), - Boolean.valueOf(sortJSONObject.getBoolean(JSON_ASCENDING))); + sortJSONObject.getBoolean(JSON_ASCENDING))); } } searchParameters.setSortOrder(sortOrder); @@ -251,11 +242,11 @@ public class RecordsManagementSearchParameters // Sort JSONArray jsonSortArray = new JSONArray(); - for (Map.Entry entry : sortOrder.entrySet()) + for (SortItem entry : sortOrder) { JSONObject jsonEntry = new JSONObject(); - jsonEntry.put(JSON_FIELD, entry.getKey().toPrefixString(namespaceService)); - jsonEntry.put(JSON_ASCENDING, entry.getValue().booleanValue()); + jsonEntry.put(JSON_FIELD, entry.property.toPrefixString(namespaceService)); + jsonEntry.put(JSON_ASCENDING, entry.assc); jsonSortArray.put(jsonEntry); } jsonObject.put(JSON_SORT, jsonSortArray); @@ -278,12 +269,12 @@ public class RecordsManagementSearchParameters return maxItems; } - public void setSortOrder(Map sortOrder) + public void setSortOrder(List sortOrder) { this.sortOrder = sortOrder; } - public Map getSortOrder() + public List getSortOrder() { return sortOrder; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchServiceImpl.java index 73254dd6e4..7923f7aa99 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchServiceImpl.java @@ -182,9 +182,9 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear searchParameters.setNamespace(RecordsManagementModel.RM_URI); // set sort - for(Entry entry : rmSearchParameters.getSortOrder().entrySet()) + for(SortItem entry : rmSearchParameters.getSortOrder()) { - searchParameters.addSort(entry.getKey().toPrefixString(namespaceService), entry.getValue().booleanValue()); + searchParameters.addSort(entry.property.toPrefixString(namespaceService), entry.assc); } // set templates diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetailsCompatibility.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetailsCompatibility.java index c4882ec968..0acc5dcb89 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetailsCompatibility.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetailsCompatibility.java @@ -21,9 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.search; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.service.namespace.NamespaceService; @@ -128,10 +126,6 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel { includedContainerTypes.add(TYPE_RECORD_CATEGORY); } -// else if ("series".equals(paramName) == true && Boolean.parseBoolean(paramValue) == true) -// { -// includedContainerTypes.add(DOD5015Model.TYPE_RECORD_SERIES); -// } } result.setIncludedContainerTypes(includedContainerTypes); @@ -139,7 +133,7 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel { // Map the sort string into the search details String[] sortPairs = sort.split(","); - Map sortOrder = new HashMap(sortPairs.length); + List sortOrder = new ArrayList(sortPairs.length); for (String sortPairString : sortPairs) { String[] sortPair = sortPairString.split("/"); @@ -149,7 +143,7 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel { isAcsending = Boolean.TRUE; } - sortOrder.put(field, isAcsending); + sortOrder.add(new SortItem(field, isAcsending)); } result.setSortOrder(sortOrder); } @@ -178,7 +172,7 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel { StringBuilder builder = new StringBuilder(64); - for (Map.Entry entry : this.savedSearchDetails.getSearchParameters().getSortOrder().entrySet()) + for (SortItem entry : this.savedSearchDetails.getSearchParameters().getSortOrder()) { if (builder.length() !=0) { @@ -186,11 +180,11 @@ public class SavedSearchDetailsCompatibility implements RecordsManagementModel } String order = "desc"; - if (Boolean.TRUE.equals(entry.getValue()) == true) + if (entry.assc == true) { order = "asc"; } - builder.append(entry.getKey().toPrefixString(this.namespaceService)) + builder.append(entry.property.toPrefixString(this.namespaceService)) .append("/") .append(order); } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SortItem.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SortItem.java new file mode 100644 index 0000000000..925b1d3193 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SortItem.java @@ -0,0 +1,15 @@ +package org.alfresco.module.org_alfresco_module_rm.search; + +import org.alfresco.service.namespace.QName; + +/*package*/ class SortItem +{ + public QName property = null; + public boolean assc = true; + public SortItem(QName property, boolean assc) + { + this.property = property; + this.assc = assc; + } + +} From 63b90e15584c7c262e0a673e0a44cb7980ba83cd Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 12 Jun 2013 12:21:53 +0000 Subject: [PATCH 11/21] Creating an RM site was not possible git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50953 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RecordsManagementSearchParameters.java | 105 ++++++++++-------- 1 file changed, 57 insertions(+), 48 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java index a81f68b19c..009679f6b3 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/RecordsManagementSearchParameters.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.json.JSONArray; @@ -36,7 +37,15 @@ import org.json.JSONObject; */ @SuppressWarnings("serial") public class RecordsManagementSearchParameters -{ +{ + /** Default sort order */ + private static final List DEFAULT_SORT_ORDER = new ArrayList() + { + { + add(new SortItem(ContentModel.PROP_NAME, Boolean.TRUE)); + } + }; + /** Default templates */ private static final Map DEFAULT_TEMPLATES = new HashMap() { @@ -63,24 +72,24 @@ public class RecordsManagementSearchParameters put("vitalRecordReviewPeriod", "%(rma:recordSearchVitalRecordReviewPeriod)"); } }; - + /** Default included container types */ private static final List DEFAULT_INCLUDED_CONTAINER_TYPES = Collections.emptyList(); - + /** Max items */ private int maxItems = 500; - + private boolean includeRecords = true; private boolean includeUndeclaredRecords = false; private boolean includeVitalRecords = false; private boolean includeRecordFolders = true; private boolean includeFrozen = false; private boolean includeCutoff = false; - + private List includedContainerTypes = DEFAULT_INCLUDED_CONTAINER_TYPES; - private List sortOrder; + private List sortOrder = DEFAULT_SORT_ORDER; private Map templates = DEFAULT_TEMPLATES; - + private static final String JSON_MAXITEMS = "maxitems"; private static final String JSON_RECORDS = "records"; private static final String JSON_UNDECLAREDRECORDS = "undeclaredrecords"; @@ -92,9 +101,9 @@ public class RecordsManagementSearchParameters private static final String JSON_SORT = "sort"; private static final String JSON_FIELD = "field"; private static final String JSON_ASCENDING = "ascending"; - + /** - * { + * { * "maxItems" : 500, * "records" : true, * "undeclaredrecords" : false, @@ -102,19 +111,19 @@ public class RecordsManagementSearchParameters * "recordfolders" : false, * "frozen" : false, * "cutoff" : false, - * "containertypes" : + * "containertypes" : * [ * "rma:recordSeries", * "rma:recordCategory" * ] - * "sort" : + * "sort" : * [ * { * "field" : "cm:name", * "ascending" : true * } - * ] - * } + * ] + * } */ public static RecordsManagementSearchParameters createFromJSON(String json, NamespaceService namespaceService) { @@ -128,9 +137,9 @@ public class RecordsManagementSearchParameters throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + json, e); } } - + /** - * + * * @param jsonObject * @return */ @@ -139,7 +148,7 @@ public class RecordsManagementSearchParameters try { RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); - + // Get the search parameter properties if (jsonObject.has(JSON_MAXITEMS) == true) { @@ -169,7 +178,7 @@ public class RecordsManagementSearchParameters { searchParameters.setIncludeCutoff(jsonObject.getBoolean(JSON_CUTOFF)); } - + // Get container types if (jsonObject.has(JSON_CONTAINERTYPES) == true) { @@ -182,7 +191,7 @@ public class RecordsManagementSearchParameters } searchParameters.setIncludedContainerTypes(containerTypes); } - + // Get sort details if (jsonObject.has(JSON_SORT) == true) { @@ -195,30 +204,30 @@ public class RecordsManagementSearchParameters sortJSONObject.has(JSON_ASCENDING) == true) { sortOrder.add(new SortItem( - QName.createQName(sortJSONObject.getString(JSON_FIELD), namespaceService), + QName.createQName(sortJSONObject.getString(JSON_FIELD), namespaceService), sortJSONObject.getBoolean(JSON_ASCENDING))); } - } + } searchParameters.setSortOrder(sortOrder); } - + return searchParameters; } catch (JSONException e) { throw new AlfrescoRuntimeException("Unable to create records management search parameters from json string. " + jsonObject.toString(), e); - } + } } - + /** - * + * * @return */ public String toJSONString(NamespaceService namespaceService) { return toJSONObject(namespaceService).toString(); } - + public JSONObject toJSONObject(NamespaceService namespaceService) { try @@ -231,7 +240,7 @@ public class RecordsManagementSearchParameters jsonObject.put(JSON_RECORDFOLDERES, includeRecordFolders); jsonObject.put(JSON_FROZEN, includeFrozen); jsonObject.put(JSON_CUTOFF, includeCutoff); - + // Included containers JSONArray jsonArray = new JSONArray(); for (QName containerType : includedContainerTypes) @@ -239,7 +248,7 @@ public class RecordsManagementSearchParameters jsonArray.put(containerType.toPrefixString(namespaceService)); } jsonObject.put(JSON_CONTAINERTYPES, jsonArray); - + // Sort JSONArray jsonSortArray = new JSONArray(); for (SortItem entry : sortOrder) @@ -250,7 +259,7 @@ public class RecordsManagementSearchParameters jsonSortArray.put(jsonEntry); } jsonObject.put(JSON_SORT, jsonSortArray); - + return jsonObject; } catch (JSONException e) @@ -258,102 +267,102 @@ public class RecordsManagementSearchParameters throw new AlfrescoRuntimeException("Unable to generate json string for records management search parameters.", e); } } - + public void setMaxItems(int maxItems) { this.maxItems = maxItems; } - + public int getMaxItems() { return maxItems; } - + public void setSortOrder(List sortOrder) { this.sortOrder = sortOrder; } - + public List getSortOrder() { return sortOrder; } - + public void setTemplates(Map templates) { this.templates = templates; } - + public Map getTemplates() { return templates; } - + public void setIncludeRecords(boolean includeRecords) { this.includeRecords = includeRecords; } - + public boolean isIncludeRecords() { return includeRecords; } - + public void setIncludeUndeclaredRecords(boolean includeUndeclaredRecords) { this.includeUndeclaredRecords = includeUndeclaredRecords; } - + public boolean isIncludeUndeclaredRecords() { return includeUndeclaredRecords; } - + public void setIncludeVitalRecords(boolean includeVitalRecords) { this.includeVitalRecords = includeVitalRecords; } - + public boolean isIncludeVitalRecords() { return includeVitalRecords; } - + public void setIncludeRecordFolders(boolean includeRecordFolders) { this.includeRecordFolders = includeRecordFolders; } - + public boolean isIncludeRecordFolders() { return includeRecordFolders; } - + public void setIncludeFrozen(boolean includeFrozen) { this.includeFrozen = includeFrozen; } - + public boolean isIncludeFrozen() { return includeFrozen; } - + public void setIncludeCutoff(boolean includeCutoff) { this.includeCutoff = includeCutoff; } - + public boolean isIncludeCutoff() { return includeCutoff; } - + public void setIncludedContainerTypes(List includedContainerTypes) { this.includedContainerTypes = includedContainerTypes; } - + public List getIncludedContainerTypes() { return includedContainerTypes; From 3882980ca51543aa78b8072051c6ae65d6653b8d Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 12 Jun 2013 16:42:47 +0000 Subject: [PATCH 12/21] RM-735 (DOD Recert: Bugs on the "Edit Custom Metadata" page) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50970 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rma/custompropdefinitions.get.json.ftl | 78 +++++++-------- .../script/CustomPropertyDefinitionPut.java | 94 ++++++++++++------- 2 files changed, 101 insertions(+), 71 deletions(-) diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinitions.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinitions.get.json.ftl index bbdee48371..083a4cc902 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinitions.get.json.ftl +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/custompropdefinitions.get.json.ftl @@ -1,43 +1,43 @@ <#escape x as jsonUtils.encodeJSONString(x)> { - "data": - { - "customProperties": - { - <#list customProps as prop> - "${prop.name.toPrefixString()}": - { - "dataType": "<#if prop.dataType??>${prop.dataType.name.toPrefixString()}", - "label": "${prop.title!""}", - "description": "${prop.description!""}", - "mandatory": ${prop.mandatory?string}, - "multiValued": ${prop.multiValued?string}, - "defaultValue": "${prop.defaultValue!""}", - "protected": ${prop.protected?string}, - "propId": "${prop.name.localName}", - "constraintRefs": - [ - <#list prop.constraints as con> - { - "name": "${con.constraint.shortName!""}", - "title": "${con.title!""}", - "type": "${con.constraint.type!""}", - "parameters": - { - <#-- Basic implementation. Only providing 2 hardcoded parameters. --> - <#assign lov = con.constraint.parameters["allowedValues"]> - "caseSensitive": ${con.constraint.parameters["caseSensitive"]?string}, - "listOfValues" : - [ - <#list lov as val>"${val}"<#if val_has_next>, - ] - } - }<#if con_has_next>, - - ] - }<#if prop_has_next>, - - } - } + "data": + { + "customProperties": + { + <#list customProps as prop> + "${prop.name.toPrefixString()}": + { + "dataType": "<#if prop.dataType??>${prop.dataType.name.toPrefixString()}", + "label": "${prop.title!""}", + "description": "${prop.description!""}", + "mandatory": ${prop.mandatory?string}, + "multiValued": ${prop.multiValued?string}, + "defaultValue": "${prop.defaultValue!""}", + "protected": ${prop.protected?string}, + "propId": "${prop.name.localName}", + "constraintRefs": + [ + <#list prop.constraints as con> + { + "name": "${con.constraint.shortName!""}", + "title": "${con.constraint.title!""}", + "type": "${con.constraint.type!""}", + "parameters": + { + <#-- Basic implementation. Only providing 2 hardcoded parameters. --> + <#assign lov = con.constraint.parameters["allowedValues"]> + "caseSensitive": ${con.constraint.parameters["caseSensitive"]?string}, + "listOfValues" : + [ + <#list lov as val>"${val}"<#if val_has_next>, + ] + } + }<#if con_has_next>, + + ] + }<#if prop_has_next>, + + } + } } \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java index 71f11e7c68..9567e4b5b0 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/CustomPropertyDefinitionPut.java @@ -22,24 +22,27 @@ import java.io.IOException; import java.io.Serializable; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import org.alfresco.module.org_alfresco_module_rm.CustomMetadataException; +import org.alfresco.module.org_alfresco_module_rm.PropertyAlreadyExistsMetadataException; import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService; +import org.alfresco.service.cmr.dictionary.ConstraintDefinition; import org.alfresco.service.namespace.QName; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; import org.springframework.extensions.surf.util.ParameterCheck; import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.extensions.webscripts.WebScriptRequest; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; /** * Implementation for Java backed webscript to update RM custom property definitions * in the custom model. - * + * * @author Neil McErlean */ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript @@ -86,30 +89,30 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je); } - + return ftlModel; } /** * Applies custom properties. - * @throws CustomMetadataException + * @throws CustomMetadataException */ protected Map handlePropertyDefinitionUpdate(WebScriptRequest req, JSONObject json) throws JSONException, CustomMetadataException { Map result = new HashMap(); - + Map params = getParamsFromUrlAndJson(req, json); - + QName propertyQName; propertyQName = updatePropertyDefinition(params); String localName = propertyQName.getLocalName(); - + result.put(PROP_ID, localName); - + String urlResult = req.getServicePath(); result.put(URL, urlResult); - + return result; } @@ -117,15 +120,16 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript * If label has a non-null value, it is set on the property def. * If constraintRef has a non-null value, it is set on this propDef. * If constraintRef has a null value, all constraints for that propDef are removed. - * + * * @param params * @return - * @throws CustomMetadataException + * @throws CustomMetadataException */ protected QName updatePropertyDefinition(Map params) throws CustomMetadataException { QName result = null; - + boolean updated = false; + String propId = (String)params.get(PROP_ID); ParameterCheck.mandatoryString("propId", propId); @@ -135,45 +139,71 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript throw new WebScriptException(Status.STATUS_NOT_FOUND, "Could not find property definition for: " + propId); } - + if (params.containsKey(PARAM_CONSTRAINT_REF)) { - String constraintRef = (String)params.get(PARAM_CONSTRAINT_REF); - - if (constraintRef == null) - { - result = rmAdminService.removeCustomPropertyDefinitionConstraints(propQName); - } - else - { - QName constraintRefQName = QName.createQName(constraintRef, namespaceService); - result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName); - } + String constraintRef = (String)params.get(PARAM_CONSTRAINT_REF); + List constraints = rmAdminService.getCustomPropertyDefinitions().get(propQName).getConstraints(); + + if (constraintRef == null) + { + result = rmAdminService.removeCustomPropertyDefinitionConstraints(propQName); + updated = constraints.isEmpty() ? false : true; + } + else + { + boolean exists = false; + for (ConstraintDefinition constraintDefinition : constraints) + { + if (constraintDefinition.getConstraint().getShortName().equalsIgnoreCase(constraintRef)) + { + exists = true; + break; + } + } + if (exists == false) + { + QName constraintRefQName = QName.createQName(constraintRef, namespaceService); + result = rmAdminService.setCustomPropertyDefinitionConstraint(propQName, constraintRefQName); + updated = true; + } + } } if (params.containsKey(PARAM_LABEL)) { String label = (String)params.get(PARAM_LABEL); - result = rmAdminService.updateCustomPropertyDefinitionName(propQName, label); + try + { + result = rmAdminService.updateCustomPropertyDefinitionName(propQName, label); + } + catch (PropertyAlreadyExistsMetadataException ex) + { + if (updated == false) + { + String propIdAsString = rmAdminService.getQNameForClientId(label).toPrefixString(namespaceService); + throw new PropertyAlreadyExistsMetadataException(propIdAsString); + } + } } return result; } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") protected Map getParamsFromUrlAndJson(WebScriptRequest req, JSONObject json) throws JSONException { Map params; params = new HashMap(); - + Map templateVars = req.getServiceMatch().getTemplateVars(); String propId = templateVars.get(PROP_ID); if (propId != null) { params.put(PROP_ID, (Serializable)propId); } - + for (Iterator iter = json.keys(); iter.hasNext(); ) { String nextKeyString = (String)iter.next(); @@ -182,10 +212,10 @@ public class CustomPropertyDefinitionPut extends BaseCustomPropertyWebScript { nextValueString = json.getString(nextKeyString); } - + params.put(nextKeyString, nextValueString); } - + return params; } } \ No newline at end of file From 93e343877e31c405a4b10496e98ca206ed71fbec Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 12 Jun 2013 20:00:49 +0000 Subject: [PATCH 13/21] RM-736 (DOD Recert: Bugs on the "List of Values" page) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50975 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../caveat/ScriptConstraint.java | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java index 2c3598d20d..4e9dec35d1 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/caveat/ScriptConstraint.java @@ -28,29 +28,30 @@ import java.util.List; import java.util.Set; import org.alfresco.service.cmr.security.AuthorityService; +import org.apache.commons.lang.StringUtils; import org.json.JSONArray; import org.json.JSONObject; public class ScriptConstraint implements Serializable { /** - * + * */ private static final long serialVersionUID = 1L; private RMConstraintInfo info; - + private RMCaveatConfigService rmCaveatconfigService; - + private AuthorityService authorityService; - + ScriptConstraint(RMConstraintInfo info, RMCaveatConfigService rmCaveatconfigService, AuthorityService authorityService) { this.info = info; - this.rmCaveatconfigService = rmCaveatconfigService; + this.rmCaveatconfigService = rmCaveatconfigService; this.authorityService = authorityService; } - + public void setTitle(String title) { info.setTitle(title); @@ -63,49 +64,49 @@ public class ScriptConstraint implements Serializable { info.setName(name); } - + public String getName() { String xxx = info.getName().replace(":", "_"); return xxx; } - + public boolean isCaseSensitive() { return info.isCaseSensitive(); } - + public String[] getAllowedValues() { return info.getAllowedValues(); } - + public ScriptConstraintAuthority[] getAuthorities() { Map> values = rmCaveatconfigService.getListDetails(info.getName()); - + if (values == null) { return new ScriptConstraintAuthority[0]; } - + // Here with some data to return Set authorities = values.keySet(); - + ArrayList constraints = new ArrayList(values.size()); for(String authority : authorities) { ScriptConstraintAuthority constraint = new ScriptConstraintAuthority(); constraint.setAuthorityName(authority); constraint.setValues(values.get(authority)); - constraints.add(constraint); + constraints.add(constraint); } - + ScriptConstraintAuthority[] retVal = constraints.toArray(new ScriptConstraintAuthority[constraints.size()]); - - return retVal; + + return retVal; } - + /** * updateTitle */ @@ -114,7 +115,7 @@ public class ScriptConstraint implements Serializable info.setTitle(newTitle); rmCaveatconfigService.updateRMConstraintTitle(info.getName(), newTitle) ; } - + /** * updateAllowedValues */ @@ -123,7 +124,7 @@ public class ScriptConstraint implements Serializable info.setAllowedValues(allowedValues); rmCaveatconfigService.updateRMConstraintAllowedValues(info.getName(), allowedValues); } - + /** * Update a value * @param values @@ -133,7 +134,7 @@ public class ScriptConstraint implements Serializable { for(int i = 0; i < bodge.length(); i++) { - + JSONObject obj = bodge.getJSONObject(i); String value = obj.getString("value"); JSONArray authorities = obj.getJSONArray("authorities"); @@ -142,10 +143,10 @@ public class ScriptConstraint implements Serializable { aList.add(authorities.getString(j)); } - rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList); - } + rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, aList); + } } - + /** * Update a value * @param values @@ -154,27 +155,27 @@ public class ScriptConstraint implements Serializable public void updateValues(String value, String[] authorities) { List list = Arrays.asList(authorities); - rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list); + rmCaveatconfigService.updateRMConstraintListValue(info.getName(), value, list); } - + /** * Cascade delete an authority * @param authority */ public void deleteAuthority(String authority) { - + } - + /** * Cascade delete a value * @param value */ public void deleteValue(String value) { - + } - + /** * Get a single value @@ -184,7 +185,7 @@ public class ScriptConstraint implements Serializable public ScriptConstraintValue getValue(String value) { ScriptConstraintValue[] values = getValues(); - + for(ScriptConstraintValue val : values) { if(val.getValueName().equalsIgnoreCase(value)) @@ -194,39 +195,39 @@ public class ScriptConstraint implements Serializable } return null; } - + public ScriptConstraintValue[] getValues() { // authority, values Map> details = rmCaveatconfigService.getListDetails(info.getName()); - + if (details == null) { details = new HashMap>(); } - + // values, authorities Map> pivot = PivotUtil.getPivot(details); - + // Here with some data to return Set values = pivot.keySet(); - + ArrayList constraints = new ArrayList(pivot.size()); for(String value : values) { ScriptConstraintValue constraint = new ScriptConstraintValue(); constraint.setValueName(value); constraint.setValueTitle(value); - + Listauthorities = pivot.get(value); List sauth = new ArrayList(); for(String authority : authorities) { ScriptAuthority a = new ScriptAuthority(); a.setAuthorityName(authority); - + String displayName = authorityService.getAuthorityDisplayName(authority); - if(displayName != null) + if(StringUtils.isNotBlank(displayName)) { a.setAuthorityTitle(displayName); } @@ -236,10 +237,10 @@ public class ScriptConstraint implements Serializable } sauth.add(a); } - constraint.setAuthorities(sauth); - constraints.add(constraint); + constraint.setAuthorities(sauth); + constraints.add(constraint); } - + /** * Now go through and add any "empty" values */ @@ -251,14 +252,14 @@ public class ScriptConstraint implements Serializable constraint.setValueName(value); constraint.setValueTitle(value); List sauth = new ArrayList(); - constraint.setAuthorities(sauth); + constraint.setAuthorities(sauth); constraints.add(constraint); } } - - + + ScriptConstraintValue[] retVal = constraints.toArray(new ScriptConstraintValue[constraints.size()]); return retVal; } - + } From 6221898e61c3e78774cb4da9965641b2fe46e228 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 13 Jun 2013 07:20:49 +0000 Subject: [PATCH 14/21] DOD Recert: Disposition date is now correctly calculated with taken from last disposition action date. * TC 8-2 multi stage disposition now works as expected git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@50978 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../action/RMActionExecuterAbstractBase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java index 6623bf9dc0..b5bf2d39ef 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/action/RMActionExecuterAbstractBase.java @@ -496,7 +496,8 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra // Get the period properties value QName periodProperty = nextDispositionActionDefinition.getPeriodProperty(); - if (periodProperty != null) + if (periodProperty != null && + RecordsManagementModel.PROP_DISPOSITION_AS_OF.equals(periodProperty) == false) { // doesn't matter if the period property isn't set ... the asOfDate will get updated later // when the value of the period property is set From 7fad3a8b3dedc360667ee4f0bf32f87c7e5a4ae1 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 14 Jun 2013 05:31:06 +0000 Subject: [PATCH 15/21] DOD Recert: RM Audit * improved display so it's easier to see what's going on * audit user creation git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51082 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RecordsManagementAuditServiceImpl.java | 87 +++++++++++++------ 1 file changed, 60 insertions(+), 27 deletions(-) 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 bc590d3df8..117d3b1e29 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 @@ -326,6 +326,10 @@ public class RecordsManagementAuditServiceImpl new AuditEvent("createDispositionSchedule", MSG_CREATE_DISPOSITION_SCHEDULE)); this.auditEvents.put("unfreeze", new AuditEvent("unfreeze", MSG_UNFREEZE)); + + // Added for DOD compliance + this.auditEvents.put("createPerson", + new AuditEvent("createPerson", "User Created")); } @Override @@ -345,7 +349,11 @@ public class RecordsManagementAuditServiceImpl policyComponent.bindClassBehaviour( BeforeDeleteNodePolicy.QNAME, RecordsManagementModel.ASPECT_RECORD_COMPONENT_ID, - new JavaBehaviour(this, "beforeDeleteNode")); + new JavaBehaviour(this, "beforeDeleteNode")); + policyComponent.bindClassBehaviour( + OnCreateNodePolicy.QNAME, + ContentModel.TYPE_PERSON, + new JavaBehaviour(this, "onCreatePersonNode")); } @Override @@ -477,7 +485,12 @@ public class RecordsManagementAuditServiceImpl { auditRMEvent(childAssocRef.getChildRef(), RM_AUDIT_EVENT_CREATE_RM_OBJECT, null, null); } - + + public void onCreatePersonNode(ChildAssociationRef childAssocRef) + { + auditRMEvent(childAssocRef.getChildRef(), "createPerson", null, null); + } + /** * {@inheritDoc} * @since 3.2 @@ -509,19 +522,9 @@ public class RecordsManagementAuditServiceImpl { // Deleted nodes will not be available at the end of the transaction. The data needs to // be extracted now and the audit entry needs to be created now. - Map auditMap = new HashMap(13); - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME), - eventName); - // Action node - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE), - nodeRef); + Map auditMap = buildAuditMap(nodeRef, eventName); auditMap = auditComponent.recordAuditValues(RecordsManagementAuditService.RM_AUDIT_PATH_ROOT, auditMap); + if (logger.isDebugEnabled()) { logger.debug("RM Audit: Audited node deletion: \n" + auditMap); @@ -559,6 +562,31 @@ public class RecordsManagementAuditServiceImpl // That is it. The values are queued for the end of the transaction. } } + + /** + * Helper method to build audit map + * + * @param nodeRef + * @param eventName + * @return + * @since 2.0.3 + */ + private Map buildAuditMap(NodeRef nodeRef, String eventName) + { + Map auditMap = new HashMap(13); + auditMap.put( + AuditApplication.buildPath( + RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, + RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME), + eventName); + // Action node + auditMap.put( + AuditApplication.buildPath( + RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, + RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE), + nodeRef); + return auditMap; + } /** * A stateless transaction listener for RM auditing. This component picks up the data of @@ -619,20 +647,13 @@ public class RecordsManagementAuditServiceImpl RMAuditNode auditedNode = entry.getValue(); - Map auditMap = new HashMap(13); // Action description String eventName = auditedNode.getEventName(); - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NAME), - eventName); - // Action node - auditMap.put( - AuditApplication.buildPath( - RecordsManagementAuditService.RM_AUDIT_SNIPPET_EVENT, - RecordsManagementAuditService.RM_AUDIT_SNIPPET_NODE), - nodeRef); + + Map auditMap = buildAuditMap(nodeRef, eventName); + + // TODO do we care if the before and after are null?? + // Property changes Map propertiesBefore = auditedNode.getNodePropertiesBefore(); Map propertiesAfter = auditedNode.getNodePropertiesAfter(); @@ -652,6 +673,7 @@ public class RecordsManagementAuditServiceImpl RecordsManagementAuditService.RM_AUDIT_SNIPPET_CHANGES, RecordsManagementAuditService.RM_AUDIT_SNIPPET_AFTER), (Serializable) deltaPair.getSecond()); + // Audit it if (logger.isDebugEnabled()) { @@ -1224,7 +1246,18 @@ public class RecordsManagementAuditServiceImpl json.put("userRole", entry.getUserRole() == null ? "": entry.getUserRole()); json.put("fullName", entry.getFullName() == null ? "": entry.getFullName()); json.put("nodeRef", entry.getNodeRef() == null ? "": entry.getNodeRef()); - json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); + + if (entry.getEvent().equals("createPerson") == true && entry.getNodeRef() != null) + { + NodeRef nodeRef = entry.getNodeRef(); + String userName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME); + json.put("nodeName", userName == null ? "": userName); + } + else + { + json.put("nodeName", entry.getNodeName() == null ? "": entry.getNodeName()); + } + json.put("nodeType", entry.getNodeType() == null ? "": entry.getNodeType()); json.put("event", entry.getEvent() == null ? "": getAuditEventLabel(entry.getEvent())); json.put("identifier", entry.getIdentifier() == null ? "": entry.getIdentifier()); From 9930fcbe4b081f2a4c204583c939fccc6cd35efc Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 14 Jun 2013 10:20:44 +0000 Subject: [PATCH 16/21] DOD Recert: Fix upgrade issue git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51099 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../RecordsManagementAdminServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 b61fc1da5b..3b6b7de0ed 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 @@ -1200,7 +1200,8 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin String compoundID = this.getCompoundIdFor(source, target); if (existsLabel(compoundID)) { - throw new IllegalArgumentException(I18NUtil.getMessage(MSG_REF_LABEL_IN_USE, compoundID)); + return null; + //throw new IllegalArgumentException(I18NUtil.getMessage(MSG_REF_LABEL_IN_USE, compoundID)); } NodeRef modelRef = getCustomModelRef(""); // defaults to RM_CUSTOM_URI From 58b6001c5f07a814a052c2f1ab7debb799ad52c9 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 14 Jun 2013 11:38:57 +0000 Subject: [PATCH 17/21] DOD Recert: Simple support for event and property filtering on audit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51108 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- build.gradle | 5 +- .../RecordsManagementAuditServiceImpl.java | 47 +++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ca38580ce5..aea74c6c88 100644 --- a/build.gradle +++ b/build.gradle @@ -210,7 +210,7 @@ subprojects { copy { from "${configModuleDir}" include "${moduleProperties}" - include "${fileMapping}" + include "${fileMapping}" into assembleDir } @@ -222,7 +222,8 @@ subprojects { copy { from configDir exclude "**/${moduleProperties}" - exclude "**/${fileMapping}" + exclude "**/${fileMapping}" + exclude "**/dev-context.xml" into "${assembleDir}/config" } 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 117d3b1e29..994ea8dbb0 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 @@ -768,7 +768,7 @@ public class RecordsManagementAuditServiceImpl * @param reportFormat Format to write the audit trail in, ignored if writer is null */ private void getAuditTrailImpl( - RecordsManagementAuditQueryParameters params, + final RecordsManagementAuditQueryParameters params, final List results, final Writer writer, final ReportFormat reportFormat) @@ -811,6 +811,7 @@ public class RecordsManagementAuditServiceImpl return false; } + Date timestamp = new Date(time); String eventName = null; String fullName = null; @@ -872,6 +873,22 @@ public class RecordsManagementAuditServiceImpl return true; } + // filter out events if set + if (params.getEvent() != null && + params.getEvent().endsWith(eventName) == false) + { + // skip it + return true; + } + + + if (params.getProperty() != null && + getChangedProperties(beforeProperties, afterProperties).contains(params.getProperty()) == false) + { + // skip it + return false; + } + // TODO: Refactor this to use the builder pattern RecordsManagementAuditEntry entry = new RecordsManagementAuditEntry( timestamp, @@ -904,6 +921,32 @@ public class RecordsManagementAuditServiceImpl return true; } + private List getChangedProperties(Map beforeProperties, Map afterProperties) + { + List changedProperties = new ArrayList(21); + + if (beforeProperties != null && afterProperties != null) + { + // add all the properties present before the audited action + for (QName valuePropName : beforeProperties.keySet()) + { + changedProperties.add(valuePropName); + } + + // add all the properties present after the audited action that + // have not already been added + for (QName valuePropName : afterProperties.keySet()) + { + if (!beforeProperties.containsKey(valuePropName)) + { + changedProperties.add(valuePropName); + } + } + } + + return changedProperties; + } + private void writeEntryToFile(RecordsManagementAuditEntry entry) { if (writer == null) @@ -947,8 +990,6 @@ public class RecordsManagementAuditServiceImpl Long fromTime = (params.getDateFrom() == null ? null : new Long(params.getDateFrom().getTime())); Long toTime = (params.getDateTo() == null ? null : new Long(params.getDateTo().getTime())); NodeRef nodeRef = params.getNodeRef(); - String eventName = params.getEvent(); - QName propertyQName = params.getProperty(); int maxEntries = params.getMaxEntries(); boolean forward = maxEntries > 0 ? false : true; // Reverse order if the results are limited From 544f2bea0d704835ee6c7d7e92f7c29a147bbb50 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Sat, 15 Jun 2013 02:32:29 +0000 Subject: [PATCH 18/21] DOD Recert: Upgrade issues * added patch to fill in missing file plan root node reference * default site id set when retrieving saved searches git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51134 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org_alfresco_module_rm/log4j.properties | 1 + .../model/recordsModel.xml | 1 - .../rm-patch-context.xml | 16 +++ .../patch/RMv2FilePlanNodeRefPatch.java | 134 ++++++++++++++++++ .../patch/RMv2ModelPatch.java | 4 +- .../search/SavedSearchDetails.java | 10 +- 6 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2FilePlanNodeRefPatch.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties b/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties index 57c59d75ba..ec18e783e1 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/log4j.properties @@ -1,2 +1,3 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.caveat=warn log4j.logger.org.alfresco.module.org_alfresco_module_rm.security.RMMethodSecurityPostProcessor=warn +log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=debug diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml index 0be4c0dee8..94c3a75c1a 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/recordsModel.xml @@ -576,7 +576,6 @@ - File Plan Component false diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml index 8c0dd0e455..0a28801ddc 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-patch-context.xml @@ -31,5 +31,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2FilePlanNodeRefPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2FilePlanNodeRefPatch.java new file mode 100644 index 0000000000..526b4756cb --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2FilePlanNodeRefPatch.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.patch; + +import java.util.List; + +import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService; +import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.patch.PatchDAO; +import org.alfresco.repo.domain.qname.QNameDAO; +import org.alfresco.repo.module.AbstractModuleComponent; +import org.alfresco.repo.policy.BehaviourFilter; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.Pair; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.BeanNameAware; + +/** + * RM v2.0 File Plan Node Ref Patch + * + * @author Roy Wetherall + */ +public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent + implements BeanNameAware, RecordsManagementModel, DOD5015Model +{ + /** Logger */ + private static Log logger = LogFactory.getLog(RMv2FilePlanNodeRefPatch.class); + + private NodeService nodeService; + private RecordsManagementService recordsManagementService; + private BehaviourFilter behaviourFilter; + private PatchDAO patchDAO; + private NodeDAO nodeDAO; + private QNameDAO qnameDAO; + + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + public void setRecordsManagementService(RecordsManagementService recordsManagementService) + { + this.recordsManagementService = recordsManagementService; + } + + public void setBehaviourFilter(BehaviourFilter behaviourFilter) + { + this.behaviourFilter = behaviourFilter; + } + + public void setPatchDAO(PatchDAO patchDAO) + { + this.patchDAO = patchDAO; + } + + public void setNodeDAO(NodeDAO nodeDAO) + { + this.nodeDAO = nodeDAO; + } + + public void setQnameDAO(QNameDAO qnameDAO) + { + this.qnameDAO = qnameDAO; + } + + /** + * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() + */ + @Override + protected void executeInternal() throws Throwable + { + if (logger.isDebugEnabled() == true) + { + logger.debug("RM Module RMv2FilePlanNodeRef Patch ..."); + } + + Pair aspectPair = qnameDAO.getQName(ASPECT_FILE_PLAN_COMPONENT); + if (aspectPair != null) + { + List records = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID()); + + if (logger.isDebugEnabled() == true) + { + logger.debug(" ... updating " + records.size() + " items" ); + } + + behaviourFilter.disableBehaviour(); + try + { + for (Long record : records) + { + Pair recordPair = nodeDAO.getNodePair(record); + NodeRef recordNodeRef = recordPair.getSecond(); + + if (nodeService.getProperty(recordNodeRef, PROP_ROOT_NODEREF) == null) + { + nodeService.setProperty(recordNodeRef, PROP_ROOT_NODEREF, recordsManagementService.getFilePlan(recordNodeRef)); + } + } + } + finally + { + behaviourFilter.enableBehaviour(); + } + } + + if (logger.isDebugEnabled() == true) + { + logger.debug(" ... complete RM Module RMv2FilePlanNodeRef Patch"); + } + + } +} diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java index 545d846d92..b4b1e5368b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/patch/RMv2ModelPatch.java @@ -43,7 +43,7 @@ public class RMv2ModelPatch extends AbstractModuleComponent implements BeanNameAware, RecordsManagementModel, DOD5015Model { /** Logger */ - private static Log logger = LogFactory.getLog(NotificationTemplatePatch.class); + private static Log logger = LogFactory.getLog(RMv2ModelPatch.class); private static long BATCH_SIZE = 100000L; @@ -80,7 +80,7 @@ public class RMv2ModelPatch extends AbstractModuleComponent { if (logger.isDebugEnabled() == true) { - logger.debug("RM Module NotificationTemplatePatch ..."); + logger.debug("RM Module RMv2ModelPatch ..."); } updateQName(QName.createQName(DOD_URI, "filePlan"), TYPE_FILE_PLAN, "TYPE"); diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetails.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetails.java index 4c0dc935a1..53d6923a03 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetails.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/search/SavedSearchDetails.java @@ -89,6 +89,8 @@ public class SavedSearchDetails extends ReportDetails public static final String SORT = "sort"; public static final String PARAMS = "params"; + private static final String DEFAULT_SITE_ID = "rm"; + /** Site id */ private String siteId; @@ -117,11 +119,11 @@ public class SavedSearchDetails extends ReportDetails JSONObject search = new JSONObject(jsonString); // Get the site id - if (search.has(SITE_ID) == false) + String siteId = DEFAULT_SITE_ID; + if (search.has(SITE_ID) == true) { - throw new AlfrescoRuntimeException("Can not create saved search details from json, because required siteid is not present. " + jsonString); - } - String siteId = search.getString(SITE_ID); + siteId = search.getString(SITE_ID); + } // Get the name if (search.has(NAME) == false) From 334725cd31c1a180a9c3ce92d1b0bdc2563cf683 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Tue, 18 Jun 2013 20:32:00 +0000 Subject: [PATCH 19/21] Search for undeclared records results in exception git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51218 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../script/slingshot/RMSearchGet.java | 154 +++++++++--------- 1 file changed, 80 insertions(+), 74 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java index df8c40bc25..fa9724d74a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/slingshot/RMSearchGet.java @@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.script.slingshot; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -53,7 +54,7 @@ import org.springframework.extensions.webscripts.WebScriptRequest; /** * RM search GET web script - * + * * @author Roy Wetherall */ public class RMSearchGet extends DeclarativeWebScript @@ -63,34 +64,34 @@ public class RMSearchGet extends DeclarativeWebScript private static final String PARAM_SORTBY = "sortby"; private static final String PARAM_FILTERS = "filters"; private static final String PARAM_MAX_ITEMS = "maxitems"; - + /** Records management search service */ protected RecordsManagementSearchService recordsManagementSearchService; - + /** Site service */ protected SiteService siteService; - + /** Namespace service */ protected NamespaceService namespaceService; - + /** Node serivce */ protected NodeService nodeService; - + /** Dictionary service */ protected DictionaryService dictionaryService; - + /** Permission service */ protected PermissionService permissionService; - + /** Person service */ protected PersonService personService; - + /** Content service */ protected ContentService contentService; - + /** Person data cache */ private Map personDataCache = null; - + /** * @param recordsManagementSearchService records management search service */ @@ -98,7 +99,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.recordsManagementSearchService = recordsManagementSearchService; } - + /** * @param siteService site service */ @@ -106,7 +107,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.siteService = siteService; } - + /** * @param namespaceService namespace service */ @@ -114,7 +115,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.namespaceService = namespaceService; } - + /** * @param nodeService node service */ @@ -122,7 +123,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.nodeService = nodeService; } - + /** * @param dictionaryService dictionary service */ @@ -130,7 +131,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.dictionaryService = dictionaryService; } - + /** * @param permissionService permission service */ @@ -138,7 +139,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.permissionService = permissionService; } - + /** * @param personService person service */ @@ -146,7 +147,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.personService = personService; } - + /** * @param contentService content service */ @@ -154,7 +155,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.contentService = contentService; } - + /* * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache) */ @@ -162,7 +163,7 @@ public class RMSearchGet extends DeclarativeWebScript protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) { // Get the site id and confirm it is valid - Map templateVars = req.getServiceMatch().getTemplateVars(); + Map templateVars = req.getServiceMatch().getTemplateVars(); String siteId = templateVars.get("site"); if (siteId == null || siteId.length() == 0) { @@ -172,50 +173,55 @@ public class RMSearchGet extends DeclarativeWebScript { throw new WebScriptException(Status.STATUS_NOT_FOUND, "Site not found."); } - + // Get the query parameter String query = req.getParameter(PARAM_QUERY); // TODO check that this is there - + String sortby = req.getParameter(PARAM_SORTBY); // TODO this is optional - + String filters = req.getParameter(PARAM_FILTERS); // TODO this is optional - + // Convert into a rm search parameter object - RecordsManagementSearchParameters searchParameters = + RecordsManagementSearchParameters searchParameters = SavedSearchDetailsCompatibility.createSearchParameters(filters, new String[]{",", "/"}, sortby, namespaceService); - + // Set the max results String maxItems = req.getParameter(PARAM_MAX_ITEMS); if (maxItems != null && maxItems.length() != 0) { searchParameters.setMaxItems(Integer.parseInt(maxItems)); } - - // Execute search + + // Execute search List results = recordsManagementSearchService.search(siteId, query, searchParameters); - + // Reset person data cache personDataCache = new HashMap(57); - - // Process the result items - Item[] items = new Item[results.size()]; - int index = 0; + + // Process the result items + List items = new ArrayList(results.size()); for (NodeRef nodeRef : results) { - items[index] = new Item(nodeRef); - index++; + // FIXME: This is a workaround for DOD Recert + // TC 3-3 Create User Groups + try + { + Item item = new Item(nodeRef); + items.add(item); + } + catch(Exception e) {} } - + // Return model Map model = new HashMap(1); - model.put("items", items); + model.put("items", items); return model; } - + /** * Item class to contain information about items being placed in model. */ @@ -231,38 +237,38 @@ public class RMSearchGet extends DeclarativeWebScript private String createdBy; private Map nodeProperties; private Map properties; - + public Item(NodeRef nodeRef) { // Set node ref this.nodeRef = nodeRef; - + // Get type QName nodeRefType = nodeService.getType(nodeRef); this.type = nodeRefType.toPrefixString(namespaceService); - + // Get properties this.nodeProperties = nodeService.getProperties(nodeRef); - + // Determine if container or not isContainer = true; if (dictionaryService.isSubClass(nodeRefType, ContentModel.TYPE_CONTENT) == true) { isContainer = false; } - + // Get parent node reference NodeRef parent = null; ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef); if (assoc != null) - { + { parent = assoc.getParentRef(); } - + if (isContainer == true) { this.size = -1; - + String displayPath = nodeService.getPath(nodeRef).toDisplayPath(nodeService, permissionService); String[] pathElements = displayPath.split("/"); if (pathElements.length >= 5) @@ -271,7 +277,7 @@ public class RMSearchGet extends DeclarativeWebScript { this.parentFolder = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME); } - + pathElements = (String[])ArrayUtils.subarray(pathElements, 5, pathElements.length); String newPath = StringUtils.join(pathElements, "/"); StringBuilder relPath = new StringBuilder("/").append(newPath); @@ -287,7 +293,7 @@ public class RMSearchGet extends DeclarativeWebScript catch (UnsupportedEncodingException e) { throw new AlfrescoRuntimeException("Could not process search results.", e); - } + } } } else @@ -299,27 +305,27 @@ public class RMSearchGet extends DeclarativeWebScript { this.size = (int)contentData.getSize(); } - + // Set the document parent name if (parent != null) { this.parentFolder = (String)nodeService.getProperty(parent, ContentModel.PROP_NAME); } - + // Set the document browse URL this.browseUrl = "document-details?nodeRef=" + nodeRef.toString(); - } - + } + this.modifiedBy = getDisplayName(getModifiedByUser()); this.createdBy = getDisplayName(getCreatedByUser()); - + // Process the custom properties properties = new HashMap(nodeProperties.size()); for (Map.Entry entry : nodeProperties.entrySet()) { QName qName = entry.getKey().getPrefixedQName(namespaceService); if (NamespaceService.SYSTEM_MODEL_1_0_URI.equals(qName.getNamespaceURI()) == false) - { + { String prefixName = qName.getPrefixString().replace(":", "_"); Serializable value = entry.getValue(); if (value instanceof NodeRef) @@ -335,7 +341,7 @@ public class RMSearchGet extends DeclarativeWebScript } } } - + private String getDisplayName(String userName) { String result = personDataCache.get(userName); @@ -356,85 +362,85 @@ public class RMSearchGet extends DeclarativeWebScript } personDataCache.put(userName, result); } - + return result; } - + public NodeRef getNodeRef() { return nodeRef; } - + public String getType() { return type; } - + public String getName() { return (String)nodeProperties.get(ContentModel.PROP_NAME); } - + public String getTitle() { return (String)nodeProperties.get(ContentModel.PROP_TITLE); } - + public String getDescription() { return (String)nodeProperties.get(ContentModel.PROP_DESCRIPTION); } - + public Date getModifiedOn() { return (Date)nodeProperties.get(ContentModel.PROP_MODIFIED); } - + public String getModifiedByUser() { return (String)nodeProperties.get(ContentModel.PROP_MODIFIER); } - + public String getModifiedBy() { return modifiedBy; } - + public Date getCreatedOn() { return (Date)nodeProperties.get(ContentModel.PROP_CREATED); } - + public String getCreatedByUser() { return (String)nodeProperties.get(ContentModel.PROP_CREATOR); } - + public String getCreatedBy() { return createdBy; } - + public String getAuthor() { return (String)nodeProperties.get(ContentModel.PROP_AUTHOR); - } - + } + public String getParentFolder() { return parentFolder; } - + public int getSize() { return size; - } - + } + public String getBrowseUrl() { return browseUrl; } - + public Map getProperties() { return properties; From 2379a050e54c5bdb46efcc001eb2d1d7210d12c5 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 19 Jun 2013 00:55:05 +0000 Subject: [PATCH 20/21] Fixed Accession Report - shows incorrect location - shows incorrect title git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/DODRECERT@51220 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../script/TransferReportPost.java | 174 ++++++++++-------- 1 file changed, 98 insertions(+), 76 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java index f95dbfa4e9..11189a4135 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/TransferReportPost.java @@ -59,14 +59,14 @@ import org.springframework.extensions.webscripts.WebScriptResponse; /** * Files a transfer report as a record. - * + * * @author Gavin Cornwell */ public class TransferReportPost extends BaseTransferWebScript { /** Logger */ private static Log logger = LogFactory.getLog(TransferReportPost.class); - + protected static final String REPORT_FILE_PREFIX = "report_"; protected static final String REPORT_FILE_SUFFIX = ".html"; protected static final String PARAM_DESTINATION = "destination"; @@ -74,65 +74,65 @@ public class TransferReportPost extends BaseTransferWebScript protected static final String RESPONSE_RECORD = "record"; protected static final String RESPONSE_RECORD_NAME = "recordName"; protected static final String FILE_ACTION = "file"; - + protected DictionaryService ddService; protected RecordsManagementActionService rmActionService; protected RecordsManagementService rmService; protected DispositionService dispositionService; - + /** * Sets the DictionaryService instance - * + * * @param ddService The DictionaryService instance */ public void setDictionaryService(DictionaryService ddService) { this.ddService = ddService; } - + /** * Sets the RecordsManagementService instance - * + * * @param rmService RecordsManagementService instance */ public void setRecordsManagementService(RecordsManagementService rmService) { this.rmService = rmService; } - + /** * Sets the disposition service - * + * * @param dispositionService disposition service */ public void setDispositionService(DispositionService dispositionService) { this.dispositionService = dispositionService; } - + /** * Sets the RecordsManagementActionService instance - * + * * @param rmActionService RecordsManagementActionService instance */ public void setRecordsManagementActionService(RecordsManagementActionService rmActionService) { this.rmActionService = rmActionService; } - + @Override protected File executeTransfer(NodeRef transferNode, - WebScriptRequest req, WebScriptResponse res, + WebScriptRequest req, WebScriptResponse res, Status status, Cache cache) throws IOException { File report = null; - + // retrieve requested format String format = req.getFormat(); Map model = new HashMap(); model.put("status", status); model.put("cache", cache); - + try { // extract the destination parameter, ensure it's present and it is @@ -140,63 +140,63 @@ public class TransferReportPost extends BaseTransferWebScript JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); if (!json.has(PARAM_DESTINATION)) { - status.setCode(HttpServletResponse.SC_BAD_REQUEST, + status.setCode(HttpServletResponse.SC_BAD_REQUEST, "Mandatory '" + PARAM_DESTINATION + "' parameter has not been supplied"); Map templateModel = createTemplateParameters(req, res, model); sendStatus(req, res, status, cache, format, templateModel); return null; } - + String destinationParam = json.getString(PARAM_DESTINATION); NodeRef destination = new NodeRef(destinationParam); - + if (!this.nodeService.exists(destination)) { - status.setCode(HttpServletResponse.SC_NOT_FOUND, + status.setCode(HttpServletResponse.SC_NOT_FOUND, "Node " + destination.toString() + " does not exist"); Map templateModel = createTemplateParameters(req, res, model); sendStatus(req, res, status, cache, format, templateModel); return null; } - + // ensure the node is a filePlan object if (!RecordsManagementModel.TYPE_RECORD_FOLDER.equals(this.nodeService.getType(destination))) { - status.setCode(HttpServletResponse.SC_BAD_REQUEST, + status.setCode(HttpServletResponse.SC_BAD_REQUEST, "Node " + destination.toString() + " is not a record folder"); Map templateModel = createTemplateParameters(req, res, model); sendStatus(req, res, status, cache, format, templateModel); return null; } - + if (logger.isDebugEnabled()) logger.debug("Filing transfer report as record in record folder: " + destination); - + // generate the report (will be in JSON format) report = generateHTMLTransferReport(transferNode); - + // file the report as a record NodeRef record = fileTransferReport(report, destination); - + if (logger.isDebugEnabled()) logger.debug("Filed transfer report as new record: " + record); - + // return success flag and record noderef as JSON JSONObject responseJSON = new JSONObject(); responseJSON.put(RESPONSE_SUCCESS, (record != null)); if (record != null) { responseJSON.put(RESPONSE_RECORD, record.toString()); - responseJSON.put(RESPONSE_RECORD_NAME, + responseJSON.put(RESPONSE_RECORD_NAME, (String)nodeService.getProperty(record, ContentModel.PROP_NAME)); } - + // setup response String jsonString = responseJSON.toString(); res.setContentType(MimetypeMap.MIMETYPE_JSON); res.setContentEncoding("UTF-8"); res.setHeader("Content-Length", Long.toString(jsonString.length())); - + // write the JSON response res.getWriter().write(jsonString); } @@ -204,14 +204,14 @@ public class TransferReportPost extends BaseTransferWebScript { throw createStatusException(je, req, res); } - + // return the file for deletion return report; } - + /** * Generates a File containing the JSON representation of a transfer report. - * + * * @param transferNode The transfer node * @return File containing JSON representation of a transfer report * @throws IOException @@ -224,16 +224,16 @@ public class TransferReportPost extends BaseTransferWebScript { // get all 'transferred' nodes NodeRef[] itemsToTransfer = getTransferNodes(transferNode); - + if (logger.isDebugEnabled()) { - logger.debug("Generating HTML transfer report for " + itemsToTransfer.length + + logger.debug("Generating HTML transfer report for " + itemsToTransfer.length + " items into file: " + report.getAbsolutePath()); } - + // create the writer writer = new FileWriter(report); - + // use RMService to get disposition authority String dispositionAuthority = null; if (itemsToTransfer.length > 0) @@ -245,11 +245,19 @@ public class TransferReportPost extends BaseTransferWebScript dispositionAuthority = ds.getDispositionAuthority(); } } - + // write the HTML header writer.write("\n"); writer.write("\n\n"); - writer.write("Transfer Report\n"); + Boolean isAccession = (Boolean)this.nodeService.getProperty(transferNode, PROP_TRANSFER_ACCESSION_INDICATOR); + if (isAccession == true) + { + writer.write("Accession Report\n"); + } + else + { + writer.write("Transfer Report\n"); + } writer.write("\n"); - writer.write("\n

Transfer Report

\n"); - + if (isAccession == true) + { + writer.write("\n

Accession Report

\n"); + } + else + { + writer.write("\n

Transfer Report

\n"); + } + writer.write(""); writer.write(""); writer.write(""); writer.write(""); writer.write("
Transfer Date:"); Date transferDate = (Date)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED); writer.write(StringEscapeUtils.escapeHtml(transferDate.toString())); writer.write("
Transfer Location:"); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode, + if (isAccession == true) + { + writer.write("NARA"); + } + else + { + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode, RecordsManagementModel.PROP_TRANSFER_LOCATION))); + } writer.write("
Performed By:"); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode, + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATOR))); writer.write("
Disposition Authority:"); writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml(dispositionAuthority) : ""); writer.write("
\n"); - + writer.write("

Transferred Items

\n"); - + // write out HTML representation of items to transfer generateTransferItemsHTML(writer, itemsToTransfer); - + // write the HTML footer writer.write(""); } @@ -292,13 +314,13 @@ public class TransferReportPost extends BaseTransferWebScript try { writer.close(); } catch (IOException ioe) {} } } - + return report; } - + /** * Generates the JSON to represent the given NodeRefs - * + * * @param writer Writer to write to * @param itemsToTransfer NodeRefs being transferred * @throws IOException @@ -320,10 +342,10 @@ public class TransferReportPost extends BaseTransferWebScript writer.write("\n"); } } - + /** * Generates the JSON to represent the given folder. - * + * * @param writer Writer to write to * @param folderNode Folder being transferred * @throws IOException @@ -332,19 +354,19 @@ public class TransferReportPost extends BaseTransferWebScript throws IOException { writer.write(""); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode, + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode, ContentModel.PROP_NAME))); writer.write(" (Unique Folder Identifier: "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode, + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(folderNode, RecordsManagementModel.PROP_IDENTIFIER))); writer.write(")\n"); - + writer.write("
\n"); - + // NOTE: we don't expect any nested folder structures so just render // the records contained in the folder. - - List assocs = this.nodeService.getChildAssocs(folderNode, + + List assocs = this.nodeService.getChildAssocs(folderNode, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef child : assocs) { @@ -354,13 +376,13 @@ public class TransferReportPost extends BaseTransferWebScript generateTransferRecordHTML(writer, childRef); } } - + writer.write("\n
\n"); } - + /** * Generates the JSON to represent the given record. - * + * * @param writer Writer to write to * @param recordNode Record being transferred * @throws IOException @@ -370,29 +392,29 @@ public class TransferReportPost extends BaseTransferWebScript { writer.write("
\n"); writer.write(" "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, ContentModel.PROP_NAME))); writer.write(" (Unique Record Identifier: "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_IDENTIFIER))); writer.write(")"); - + if (this.nodeService.hasAspect(recordNode, RecordsManagementModel.ASPECT_DECLARED_RECORD)) { Date declaredOn = (Date)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_AT); writer.write(" declared by "); - writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, + writer.write(StringEscapeUtils.escapeHtml((String)this.nodeService.getProperty(recordNode, RecordsManagementModel.PROP_DECLARED_BY))); writer.write(" on "); writer.write(StringEscapeUtils.escapeHtml(declaredOn.toString())); } - + writer.write("\n
\n"); } - + /** * Files the given transfer report as a record in the given record folder. - * + * * @param report Report to file * @param destination The destination record folder * @return NodeRef of the created record @@ -401,17 +423,17 @@ public class TransferReportPost extends BaseTransferWebScript { ParameterCheck.mandatory("report", report); ParameterCheck.mandatory("destination", destination); - + NodeRef record = null; - + Map properties = new HashMap(1); properties.put(ContentModel.PROP_NAME, report.getName()); - + // file the transfer report as an undeclared record - record = this.nodeService.createNode(destination, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, - QName.createValidLocalName(report.getName())), + record = this.nodeService.createNode(destination, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, + QName.createValidLocalName(report.getName())), ContentModel.TYPE_CONTENT, properties).getChildRef(); // Set the content @@ -419,10 +441,10 @@ public class TransferReportPost extends BaseTransferWebScript writer.setMimetype(MimetypeMap.MIMETYPE_HTML); writer.setEncoding("UTF-8"); writer.putContent(report); - + // file the node as a record - this.rmActionService.executeRecordsManagementAction(record, FILE_ACTION); - + this.rmActionService.executeRecordsManagementAction(record, FILE_ACTION); + return record; } } \ No newline at end of file From 586106f26d702d80233e465e0b0c5299d127f3b8 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 26 Jun 2013 05:08:48 +0000 Subject: [PATCH 21/21] RM: Fix build git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@51504 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rm-capabilities-context.xml | 7 +++++- .../test/capabilities/CapabilitiesTest.java | 24 +++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml index 0f381d7dd9..cf8308a1e1 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-capabilities-context.xml @@ -57,7 +57,12 @@ parent="rmBaseCapability" class="org.alfresco.module.org_alfresco_module_rm.capability.impl.ChangeOrDeleteReferencesCapability"> - + + + + RECORD + + diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/CapabilitiesTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/CapabilitiesTest.java index b52e688b3d..98de85fa68 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/CapabilitiesTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/capabilities/CapabilitiesTest.java @@ -437,7 +437,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -556,7 +556,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -677,7 +677,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -814,7 +814,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, CREATE_MODIFY_DESTROY_EVENTS, AccessStatus.ALLOWED); check(access, CREATE_MODIFY_DESTROY_FILEPLAN_METADATA, - AccessStatus.DENIED); + AccessStatus.ALLOWED); check(access, CREATE_MODIFY_DESTROY_FILEPLAN_TYPES, AccessStatus.ALLOWED); check(access, CREATE_MODIFY_DESTROY_FOLDERS, @@ -1282,7 +1282,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -1404,7 +1404,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -1525,7 +1525,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -1648,7 +1648,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.DENIED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -2134,7 +2134,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.ALLOWED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -2263,7 +2263,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.ALLOWED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -2386,7 +2386,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.ALLOWED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED); @@ -2507,7 +2507,7 @@ public class CapabilitiesTest extends BaseRMTestCase implements check(access, AUTHORIZE_NOMINATED_TRANSFERS, AccessStatus.DENIED); check(access, CHANGE_OR_DELETE_REFERENCES, - AccessStatus.UNDETERMINED); + AccessStatus.DENIED); check(access, CLOSE_FOLDERS, AccessStatus.ALLOWED); check(access, CREATE_AND_ASSOCIATE_SELECTION_LISTS, AccessStatus.ALLOWED);